cs: add «2825. Make String a Subsequence Using Cyclic Increments»
URL: https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/ Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
decfe0c0b3
commit
e5ef5167a7
1 changed files with 12 additions and 0 deletions
12
cs/make-string-a-subsequence-using-cyclic-increments.cs
Normal file
12
cs/make-string-a-subsequence-using-cyclic-increments.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue