Skip to content

Commit 940d6ca

Browse files
committed
add 2825
1 parent c1738eb commit 940d6ca

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
2825. Make String a Subsequence Using Cyclic Increments
3+
4+
LeetCode Daily Question for December 4, 2024
5+
6+
Runtime: 0 ms (beats 100.00%)
7+
Memory: 14.74 MB (beats 98.74%)
8+
*/
9+
10+
class Solution {
11+
public:
12+
bool canMakeSubsequence(const string& str1, const string& str2) {
13+
if (str2.size() > str1.size()) return false;
14+
auto i = str1.cbegin(), j = str2.cbegin();
15+
const auto end1 = str1.cend(), end2 = str2.cend();
16+
while (i != end1 && j != end2) {
17+
if (*i == *j) {
18+
++j;
19+
} else if ((*i == 'z' ? 'a' : *i + 1) == *j) {
20+
++j;
21+
}
22+
++i;
23+
}
24+
return j == end2;
25+
}
26+
};

0 commit comments

Comments
 (0)