Skip to content

Commit 24dcdc5

Browse files
committed
89
1 parent c253d3b commit 24dcdc5

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Day89/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @param {string} digits
3+
* @return {string[]}
4+
*/
5+
var letterCombinations = function(digits) {
6+
7+
let letters = {
8+
2: ['a', 'b', 'c'],
9+
3: ['d', 'e', 'f'],
10+
4: ['g', 'h', 'i'],
11+
5: ['j', 'k', 'l'],
12+
6: ['m', 'n', 'o'],
13+
7: ['p', 'q', 'r', 's'],
14+
8: ['t', 'u', 'v'],
15+
9: ['w', 'x', 'y', 'z'],
16+
}
17+
let queue = [];
18+
queue = [" "];
19+
20+
if(!digits)return [];
21+
22+
23+
for(let i=0; i < digits.length; i++){
24+
let digit = digits[i]
25+
26+
let n = queue.length;
27+
28+
for(let j=0; j < n; j++){
29+
30+
let lookUp = letters[digit];
31+
let pop = queue.shift();
32+
for(let k =0; k < lookUp.length; k++){
33+
34+
let newData = pop + lookUp[k]
35+
queue.push(newData.trim())
36+
37+
}
38+
39+
}
40+
41+
}
42+
return queue
43+
44+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
196196

197197
|Day 87| [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/)|Medium|
198198

199-
|Day 88| [526. Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement/) | [javascript]()|[:memo:](https://leetcode.com/problems/beautiful-arrangement/)|Medium|
199+
|Day 88| [526. Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement/) | [javascript]()|[:memo:](https://leetcode.com/problems/beautiful-arrangement/)|Medium|
200+
201+
|Day 89| [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/) | [javascript]()|[:memo:](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)|Medium|

0 commit comments

Comments
 (0)