Skip to content

Commit 7c646f0

Browse files
committed
Runtime: 68 ms (Top 16.25%) | Memory: 14 MB (Top 13.50%)
1 parent f1ab7c5 commit 7c646f0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/algorithms/A/Alphabet Board Path/Alphabet Board Path.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 68 ms (Top 16.25%) | Memory: 14 MB (Top 13.50%)
12
class Solution:
23
def alphabetBoardPath(self, target: str) -> str:
34
def shortestPath(r,c,tr,tc):
@@ -18,17 +19,17 @@ def shortestPath(r,c,tr,tc):
1819
c += 1
1920
if tr == 5 and pr != tr: path = path + 'D'
2021
return path
21-
22+
2223
table = ['abcde','fghij','klmno','pqrst','uvwxy','z']
2324
r,c = 0,0
2425
ans = ""
2526
for character in target:
2627
t_row = None
2728
for i,word in enumerate(table):
28-
if character in word:
29+
if character in word:
2930
t_row = i
3031
break
3132
t_col = table[i].index(character)
3233
ans += shortestPath(r,c,t_row,t_col) + '!'
3334
r,c = t_row,t_col
34-
return ans
35+
return ans

0 commit comments

Comments
 (0)