

I took advantage of the hash table and the recursive function of the specific code below
package middle;
import java.util.ArrayList;
Import the Java. Util. Arrays;
Import the Java. Util. HashMap;
import java.util.List;
import java.util.Map;
Public class number combination {
Public static void main (String [] args) {
String STR="273";
ListList=letterCombinations (STR);
System.out.println(list);
}
Public static ListLetterCombinations (String) who {
Listlist=new ArrayList<> (a);
MapThe map=new HashMap (a);
The map. The put (' 2 ', "ABC");
The map. The put (' 3 ', "def");
The map. The put (' 4 ', "ghi");
The map. The put (' 5 ', "JKL");
The map. The put (' 6 ', "mno");
Map. The put (' 7 ', "PQRS");
The map. The put (' 8 ', "tuv");
The map. The put (' 9 ', "wxyz");
Method (map, list, who, "");
return list;
}
/* *
*
* @ param map
* button mapping* @ param list
* the final list
* @ param s
* the current input numeric characters
* @ param result
* transfer characters, initial null character
*/
Public static void method (MapThe map, List The list, the String s, String result) {
If (s=="") {
return;
}
String STR=map. Get (s.c harAt (0));
For (int I=0; iString result2=result + STR. CharAt (I);
If (s.l ength () & gt; 1) {
Method (map, list, s.s ubstring (1), result2);
} else if (s.l ength ()==1) {
List. The add (result2);
}
}
}
}
Testing examples can be passed, but submit prompt when I perform error, I don't know where is the specific error

For passing bosses spend little time to help me see, really appreciate!!!!!!!!!!!!!!!!!!!!!!!!!

CodePudding user response:
S=="", the writing has a problem, is not true, so have" "crossing the line when I was back, to s.e quase (" ")CodePudding user response: