Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Leetcode 17. Letter Combinations of a Phone Number
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; //Letter Combinations of a Phone Number class Rextester { Map<String,String> phone = new HashMap<String,String>(); List<String> out = new ArrayList<>(); public static void main(String args[]) { System.out.println("Hello, World!"); } public List<String> letterCombinations(String digits) { phone.put("2","abc"); phone.put("3","def"); phone.put("4","ghi"); phone.put("5","jkl"); phone.put("6","mno"); phone.put("7","pqrs"); phone.put("8","tuv"); phone.put("9","wxyz"); if(digits.length()!=0) helper("",digits); return out; } public void helper(String combination, String digits){ if(digits.length()==0){ out.add(combination); return; } for(char c:phone.get(digits.substring(0,1)).toCharArray()){ helper(combination+c,digits.substring(1)); } } }
run
|
edit
|
history
|
help
0
laba
ArrayOperation
Rabbits in forest (leetod)
Eckhart generator with real id
With unicode change
1a
javaClassAr2
Test processing time (loop vs. contains)
Rakibul Haque
BFS in graph