Skip to content

Commit bd07941

Browse files
committed
Dec 4
1 parent fe425b4 commit bd07941

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution:
2+
def canMakeSubsequence(self, str1: str, str2: str) -> bool:
3+
l1, l2 = len(str1), len(str2)
4+
p2 = 0
5+
for p1 in range(l1):
6+
if p2 < l2 and (ord(str2[p2]) - ord(str1[p1])) % 26 <= 1:
7+
p2 += 1
8+
return p2 == l2
9+
10+
11+
def main():
12+
str1 = 'abc'
13+
str2 = 'ad'
14+
assert Solution().canMakeSubsequence(str1, str2) is True
15+
16+
str1 = 'zc'
17+
str2 = 'ad'
18+
assert Solution().canMakeSubsequence(str1, str2) is True
19+
20+
str1 = 'ab'
21+
str2 = 'd'
22+
assert Solution().canMakeSubsequence(str1, str2) is False
23+
24+
25+
if __name__ == '__main__':
26+
main()

2024-12-December-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| December 1 | [1346. Check If N and Its Double Exist](https://leetcode.com/problems/check-if-n-and-its-double-exist/) | Easy | Solved |
77
| December 2 | [1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/) | Easy | Solved |
88
| December 3 | [2109. Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string/) | Medium | Solved |
9-
| December 4 | []() | | |
9+
| December 4 | [2825. Make String a Subsequence Using Cyclic Increments](https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/) | Medium | Solved |
1010
| December 5 | []() | | |
1111
| December 6 | []() | | |
1212
| December 7 | []() | | |
@@ -39,5 +39,5 @@
3939
| Level | Problems | Solved | Unsolved |
4040
| --- | --- | --- | --- |
4141
| Easy | 2 | 2 | 0 |
42-
| Medium | 1 | 1 | 0 |
42+
| Medium | 2 | 2 | 0 |
4343
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)