Time: 0 ms (100%), Space: 17.7 MB (91.79%) - LeetHub

This commit is contained in:
Deven
2025-11-24 19:24:10 -05:00
parent 1662e01e2c
commit 675548bafa
@@ -0,0 +1,26 @@
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
mapping = {
"2": "abc",
"3": "def",
"4": "ghi",
"5": "jkl",
"6": "mno",
"7": "pqrs",
"8": "tuv",
"9": "wxyz"
}
curr = [""]
next = []
for digit in digits:
for prefix in curr:
for newChar in mapping[digit]:
next.append(f"{prefix}{newChar}")
curr = next
next = []
return curr