Letter Combinations of a Phone Number || 电话号码对应的单词
来源:互联网 发布:通达信选股软件下载 编辑:程序博客网 时间:2024/05/21 10:47
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.
Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Note:
Although the above answer is in lexicographical order, your answer could be in any order you want.
public class Solution { public String []c={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; public int []total={0,0,3,3,3,3,3,4,3,4}; public List<String> letterCombinations(String digits) { List<String> res=new LinkedList<String>(); dfs(digits,"",0,res); return res; } public void dfs(String digits,String ans,int index,List<String> res){ if(index==digits.length()){ res.add(ans); return; } int i=digits.charAt(index)-'0'; if(i<2 || i>10) return; for(int j=0;j<total[i];j++){ dfs(digits,ans+String.valueOf(c[i].charAt(j)),index+1,res); } }}
0 0
- Letter Combinations of a Phone Number || 电话号码对应的单词
- Letter Combinations of a Phone Number 电话号码的组合
- 【LeetCode-面试算法经典-Java实现】【017-Letter Combinations of a Phone Number (电话号码上的单词组合)】
- Letter Combinations of a Phone Number (电话号码字母组合) 【leetcode】
- LeetCode 17 Letter Combinations of a Phone Number(电话号码的字母组合)
- 425.Letter Combinations of a Phone Number-电话号码的字母组合(中等题)
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
- 17:Letter Combinations of a Phone Number(字母组合的电话号码)
- LeetCode: Letter Combinations of a Phone Number
- LeetCode Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- [Leetcode] Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- LeetCode18:Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- 【leetcode】Letter Combinations of a Phone Number
- LeetCode: Letter Combinations of a Phone Number
- Letter Combinations of a Phone Number
- jQuery ReferenceError: $ is not defined
- Redis主从和HA配置
- Eigen与Malab函数对照
- nyoj 108 士兵杀敌(一)
- 2014-8-10 掉落不简单
- Letter Combinations of a Phone Number || 电话号码对应的单词
- 群众请求加强革命圣地高速公路沿线户外广告整治
- asp.net&C#各种加密码解密
- python安装
- linux ssh信任登录
- AlertDialog更改标题颜色,字体等
- Centos中tomcat开机自启动
- 思维被颠覆 互联网入侵电视
- 绘制FastMM内存分配流程图(小块内存分配)