public class Solution { public List<String> letterCombinations(String digits) { LinkedList<String> que=new LinkedList<String>(); if(digits.length()==0) return que; String[] btns=new String[]{"0","1","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; que.add(""); for(int i=0;i<digits.length();i++) { String btn=btns[digits.charAt(i)-'0']; while(que.peek().length()==i) { String item=que.poll(); for(int j=0;j<btn.length();j++) que.add(item+btn.charAt(j)); } } return que; } }