Can Convert String in K Moves LeetCode solution in Python
1# Runtime: 285 ms (Top 92.79%) | Memory: 15.1 MB (Top 75.68%)2class Solution:3def canConvertString(self, s: str, t: str, k: int) -> bool:4if len(s) != len(t):5return False67cycles, extra = divmod(k, 26)8shifts = [cycles + (shift <= extra) for shift in range(26)]910for cs, ct in zip(s, t):11shift = (ord(ct) - ord(cs)) % 2612if shift == 0:13continue14if not shifts[shift]:15return False16shifts[shift] -= 11718return True