建立映射关系即可
class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if digits=="":
return []
dict1={}
dict1[2]="abc"
dict1[3]="def"
dict1[4]="ghi"
dict1[5]="jkl"
dict1[6]="mno"
dict1[7]="pqrs"
dict1[8]="tuv"
dict1[9]="wxyz"
res=[""]
for d in digits:
res1=[]
for t in res:
for s in dict1[int(d)]:
res1.append(t+s)
res = res1
return res