https://leetcode.com/problems/letter-combinations-of-a-phone-number/

Given a digit string, return all possible letter combinations that the number could represent.

A mapping of digit to letters (just like on the telephone buttons) is given below.

曾经java 老师他的面试题,当时竟然不会 = =

典型DFS的题,每种可能都试 然后 回溯, DFS 唯一需要注意的是回溯 回复到之前的状态,此题即remove latest added letter.

当然也可以用BFS // 测试用例貌似没有 0 和 1

****** when you get a digit '0', '1', ... '9'. convert to integer by using digit - '0'

results matching ""

    No results matching ""