欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

leetcode 17. 电话号码的字母组合

程序员文章站 2022-04-16 23:53:20
...

没啥思路直接写就完了···

dict_ = {"2":"abc","3":"def","4":"ghi","5":"jkl","6":"mno","7":"pqrs","8":"tuv","9":"wxyz"}
        res = []
        for i in digits:
            if len(res)==0:
                res.extend([j for j in dict_[i]])
            else:
                res = [w+j for j in dict_[i] for w in res]
        return res

leetcode 17. 电话号码的字母组合