2825. Make String a Subsequence Using Cyclic Increments
class Solution:
def canMakeSubsequence(self, str1: str, str2: str) -> bool:
if len(str2) > len(str1):
return False
str2 = list(str2)
head = str2[0]
def getIncrementedChar(char):
if char == 'z':
return 'a'
return chr(ord(char) + 1)
for e in str1:
incrementedChar = getIncrementedChar(e)
if e == head or incrementedChar == head:
str2.pop(0)
if not str2:
break
head = str2[0]
return len(str2) == 0