Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
Simple imitation for show banners on priorities
Fraction implementation using oops in java
dimond of stars
pre
темп
hondaa11
CRUD vehicules
Size and signedness of Java ints and longs
1.5
final method
Please log in to post a comment.