From e5ef5167a74181776bee3563149e52946b23c288 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 4 Dec 2024 13:41:16 +0100 Subject: [PATCH] =?UTF-8?q?cs:=20add=20=C2=AB2825.=20Make=20String=20a=20S?= =?UTF-8?q?ubsequence=20Using=20Cyclic=20Increments=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URL: https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/ Signed-off-by: Matej Focko --- ...e-string-a-subsequence-using-cyclic-increments.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cs/make-string-a-subsequence-using-cyclic-increments.cs diff --git a/cs/make-string-a-subsequence-using-cyclic-increments.cs b/cs/make-string-a-subsequence-using-cyclic-increments.cs new file mode 100644 index 0000000..67367e4 --- /dev/null +++ b/cs/make-string-a-subsequence-using-cyclic-increments.cs @@ -0,0 +1,12 @@ +public class Solution { + public bool CanMakeSubsequence(string str1, string str2) { + int j = 0; + for (int i = 0; i < str1.Length && j < str2.Length; ++i) { + if (str1[i] == str2[j] || str1[i] + 1 == str2[j] || str1[i] - 25 == str2[j]) { + ++j; + } + } + + return j == str2.Length; + } +}