Skip to content

Commit 5d6e161

Browse files
committed
Runtime: 285 ms (Top 92.79%) | Memory: 15.1 MB (Top 75.68%)
1 parent 4097a55 commit 5d6e161

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/C/Can Convert String in K Moves/Can Convert String in K Moves.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# Runtime: 285 ms (Top 92.79%) | Memory: 15.1 MB (Top 75.68%)
12
class Solution:
23
def canConvertString(self, s: str, t: str, k: int) -> bool:
34
if len(s) != len(t):
45
return False
5-
6+
67
cycles, extra = divmod(k, 26)
78
shifts = [cycles + (shift <= extra) for shift in range(26)]
89

@@ -13,5 +14,5 @@ def canConvertString(self, s: str, t: str, k: int) -> bool:
1314
if not shifts[shift]:
1415
return False
1516
shifts[shift] -= 1
16-
17+
1718
return True

0 commit comments

Comments
 (0)