leetcode Letter Combinations of a Phone Number(Java)
来源:互联网 发布:淘宝客服主管工资 编辑:程序博客网 时间:2024/05/19 03:28
题目链接:点击打开链接
类型:字符串处理
解法:建立词典库,将新来的每个数字字符对应的多个字符加到每个结果字符串中
public class Solution { public List<String> letterCombinations(String digits) {List<String> s = new LinkedList<>();String[] map = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};if (digits == null || digits.length() < 1)return s;s.add("");for (int i = 0 ; i < digits.length() ; i++){String curr = map[digits.charAt(i)-'0'];List<String> temp = new LinkedList<>();for (int j = 0 ; j < s.size() ; j++){for (char iter : curr.toCharArray()){temp.add(s.get(j) + iter);}}s = temp;}return s; }}
阅读全文
0 0
- 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
- 【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
- 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
- 【leetcode】Letter Combinations of a Phone Number
- [LeetCode] Letter Combinations of a Phone Number
- leetcode: Letter Combinations of a Phone Number
- 朱光潜谈读书
- mybatis常用代码
- 注解和注释以及Spring和SpringMVC常用的注解
- d3对于数组的处理
- android 获取http请求json数据 package com.my.gethttpjsondata; import java.io.BufferedReader; import java.
- leetcode Letter Combinations of a Phone Number(Java)
- Android:XML解析
- 【最短路中求至少需要的最短跳跃距离】poj 2253 Frogger
- 经验模态分解法简析(转)
- [转载]使用 CSS 处理文本过长和意外超出的方法和技巧
- 增强for
- 点击两次返回键退出应用
- iOS 底层解析weak的实现原理(包含weak对象的初始化,引用,释放的分析)
- 网络中出现TCP、UDP粘包、分包的两点解决办法