17. Letter Combinations of a Phone Number
# Medium
Combination of subsets and permutation methods, because start from next index instead of 0 during combination.
Solution:
Build a dictionary for mapping digit to characters.
Assume
s=['abc', 'def', 'ghi']
, there are 2 nested layers. Each layer needs to move to next in stead of starting from first char as permutation method. Only outside layer should remember its index.Stop condition: len(level) == len(s)
Last updated
Was this helpful?