作者:
dont 2024-12-04 20:38:132825. Make String a Subsequence Using Cyclic Increments
## 思路
用pointer i 紀錄目前對應的str2字元
掃str1比對對應的str2字元 有match就i+1
如果指標到底就回傳TRUE
## CODE
```python
class Solution:
def canMakeSubsequence(self, str1: str, str2: str) -> bool:
next_char = {}
for i in range(25):
next_char[chr(ord('a') + i)] = chr(ord('a') + i + 1)
next_char['z'] = 'a'
i = 0
for ch in str1:
if str2[i] == ch or str2[i] == next_char[ch]:
i += 1
if i == len(str2):
return True
return False
```