h*d
2 楼
没有人知道吗?
j*t
3 楼
这是trie吗? 应该是一个recursive search吧.
s*y
4 楼
static final int phoneLength=7;
char [][] keypad={{'0'},{'1'},{'a','b','c'},{'d','e','f'},
{'g','h','i'},{'j','k','l'},{'m','n','o'},
{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
void printWords(int [] phoneNumber){
char result []= new char [phoneLength];
doPrintWords(phoneNumber,result,0);
}
void doPrintWords(int []phoneNumber, char []result, int curIndex){
if(curIndex==phoneLength){
System.out.println(result);
return;
}
if(phoneNumber[curIndex]==0){
result[curIndex]='0';
doPrintWords(phoneNumber,result, curIndex+1);
}
else if(phoneNumber[curIndex]==1){
result[curIndex]='1';
doPrintWords(phoneNumber,result, curIndex+1);
}
else{
int numOfchar=keypad[phoneNumber[curIndex]].length;
for(int i=0;i result[curIndex]=keypad[phoneNumber[curIndex]][i];
doPrintWords(phoneNumber,result, curIndex+1);
}
}
char [][] keypad={{'0'},{'1'},{'a','b','c'},{'d','e','f'},
{'g','h','i'},{'j','k','l'},{'m','n','o'},
{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
void printWords(int [] phoneNumber){
char result []= new char [phoneLength];
doPrintWords(phoneNumber,result,0);
}
void doPrintWords(int []phoneNumber, char []result, int curIndex){
if(curIndex==phoneLength){
System.out.println(result);
return;
}
if(phoneNumber[curIndex]==0){
result[curIndex]='0';
doPrintWords(phoneNumber,result, curIndex+1);
}
else if(phoneNumber[curIndex]==1){
result[curIndex]='1';
doPrintWords(phoneNumber,result, curIndex+1);
}
else{
int numOfchar=keypad[phoneNumber[curIndex]].length;
for(int i=0;i
doPrintWords(phoneNumber,result, curIndex+1);
}
}
h*d
5 楼
这个是print电话对应的字母吧?
【在 s********y 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: static final int phoneLength=7;
: char [][] keypad={{'0'},{'1'},{'a','b','c'},{'d','e','f'},
: {'g','h','i'},{'j','k','l'},{'m','n','o'},
: {'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
: void printWords(int [] phoneNumber){
: char result []= new char [phoneLength];
: doPrintWords(phoneNumber,result,0);
: }
: void doPrintWords(int []phoneNumber, char []result, int curIndex){
: if(curIndex==phoneLength){
【在 s********y 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: static final int phoneLength=7;
: char [][] keypad={{'0'},{'1'},{'a','b','c'},{'d','e','f'},
: {'g','h','i'},{'j','k','l'},{'m','n','o'},
: {'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
: void printWords(int [] phoneNumber){
: char result []= new char [phoneLength];
: doPrintWords(phoneNumber,result,0);
: }
: void doPrintWords(int []phoneNumber, char []result, int curIndex){
: if(curIndex==phoneLength){
c*2
8 楼
This is a lookup problem.
To use prefix tree for this: build the tree with 0-9, at the end node, store
person's name.
(This is similar to routing table lookup.)
Can also be done with hash mapping.
To use prefix tree for this: build the tree with 0-9, at the end node, store
person's name.
(This is similar to routing table lookup.)
Can also be done with hash mapping.
相关阅读
再论 mini # of swaps to sort array.Job opening in a startupanyone heard of xad.comT problem报个电面的面经和据信吧, 求安慰听说G家on-site 吃饭一天upto $35?从今天开始打算认真做Leetcode了hackerrank的xor题目黑客rank Stock Maximizecounting sort of integers (or relavent question) is the most important coding interview questions...油工还真是有钱 (转载)LinkedIn的SWE的结构谁给解释一下?Intern offer 求比较问道careercup 150 题目的复杂度请问刷完leetcode, 150,下一步该刷什么了?leetcode 的编译器是旧的还是新的?面试以后多久能接到下一轮的通知?很郁闷!找工作新手请教一个问题看来今年H1B名额第一周可能就用完了明天onsite,求bless...