Leetcode17:电话号码的字母组合
本帖最后由 Cccf$ 于 2022-11-25 17:55 编辑https://fishc.com.cn/forum.php?mod=image&aid=162529&size=300x300&key=9fd7b47745dd693f&nocache=yes&type=fixnone
https://fishc.com.cn/forum.php?mod=image&aid=162533&size=300x300&key=37931ec5b67053e2&nocache=yes&type=fixnone
https://fishc.com.cn/forum.php?mod=image&aid=162530&size=300x300&key=919325b6eabf05b6&nocache=yes&type=fixnone
https://fishc.com.cn/forum.php?mod=image&aid=162531&size=300x300&key=25ed36ad67f6b7f0&nocache=yes&type=fixnone
本帖最后由 jackz007 于 2022-11-26 20:04 编辑
def foo(s):
p = {'2' : 'abc' , '3' : 'def' , '4' : 'ghi' , '5' : 'jkl' , '6' : 'mno' , '7' : 'pqrs' , '8' : 'tuv' , '9' : 'wxyz'}
d , k , r = []) - 1] for k in range(len(s))] , len(s) , []
while k :
r . append('' . join(]] for i in range(len(s))]))
d += 1
if d > d :
while k and d > d :
k -= 1
d += 1
if k :
while k < len(s) :
d = 0
k += 1
return r
print(foo('235'))
页:
[1]