From fb0684dd2729fb14c157a66f7d8dfac945763b30 Mon Sep 17 00:00:00 2001 From: strNophix Date: Sat, 3 Sep 2022 15:59:02 +0200 Subject: [PATCH] Fixed import and formatting of leetcode 17 --- ...7_letter_combinations_of_a_phone_number.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/leetcode/17_letter_combinations_of_a_phone_number.py b/leetcode/17_letter_combinations_of_a_phone_number.py index de6b40c..7e4fea5 100644 --- a/leetcode/17_letter_combinations_of_a_phone_number.py +++ b/leetcode/17_letter_combinations_of_a_phone_number.py @@ -1,21 +1,24 @@ +from typing import List + + class Solution: def letterCombinations(self, digits: str) -> List[str]: if len(digits) == 0: return [] options = { - '2': ('a', 'b', 'c'), - '3': ('d', 'e', 'f'), - '4': ('g', 'h', 'i'), - '5': ('j', 'k', 'l'), - '6': ('m', 'n', 'o'), - '7': ('p', 'q', 'r', 's'), - '8': ('t', 'u', 'v'), - '9': ('w', 'x', 'y', 'z') + "2": ("a", "b", "c"), + "3": ("d", "e", "f"), + "4": ("g", "h", "i"), + "5": ("j", "k", "l"), + "6": ("m", "n", "o"), + "7": ("p", "q", "r", "s"), + "8": ("t", "u", "v"), + "9": ("w", "x", "y", "z"), } pools = (options[digit] for digit in digits) result = [""] for pool in pools: - result = [x+y for x in result for y in pool] + result = [x + y for x in result for y in pool] return result