Skip to content

Commit fa65c42

Browse files
author
luzhipeng
committed
feat: 每日一题2019-06-18参考答案
1 parent 384ec43 commit fa65c42

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

README.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ The data structures mainly includes:
8080

8181
## Top Problems Progress
8282

83-
- [Top 100 Liked Questions](https://leetcode.com/problemset/top-100-liked-questions/) (63 / 100)
83+
- [Top 100 Liked Questions](https://leetcode.com/problemset/top-100-liked-questions/) (67 / 100)
8484

85-
- [Top Interview Questions](https://leetcode.com/problemset/top-interview-questions/) (85 / 145)
85+
- [Top Interview Questions](https://leetcode.com/problemset/top-interview-questions/) (88 / 145)
8686

8787

8888

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ leetcode 题解,记录自己的 leetcode 解题之路。
8383

8484
## Top题目进度
8585

86-
- [Top 100 Liked Questions](https://leetcode.com/problemset/top-100-liked-questions/) (63 / 100)
86+
- [Top 100 Liked Questions](https://leetcode.com/problemset/top-100-liked-questions/) (67 / 100)
8787

88-
- [Top Interview Questions](https://leetcode.com/problemset/top-interview-questions/) (85 / 145)
88+
- [Top Interview Questions](https://leetcode.com/problemset/top-interview-questions/) (88 / 145)
8989
## 传送门
9090

9191
### leetcode 经典题目的解析
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* @lc app=leetcode id=17 lang=javascript
3+
*
4+
* [17] Letter Combinations of a Phone Number
5+
*/
6+
function backtrack(list, tempList, digits, start, keys) {
7+
if (tempList.length === digits.length) {
8+
return list.push(tempList.join(''));
9+
}
10+
11+
for (let i = start; i < digits.length; i++) {
12+
const chars = keys[digits[i]];
13+
for (let j = 0; j < chars.length; j++) {
14+
tempList.push(chars[j]);
15+
backtrack(list, tempList, digits, i + 1, keys);
16+
tempList.pop();
17+
}
18+
}
19+
}
20+
/**
21+
* @param {string} digits
22+
* @return {string[]}
23+
*/
24+
var letterCombinations = function(digits) {
25+
if (digits.length === 0) return [];
26+
// Input:Digit string "23"
27+
// Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
28+
const keys = [
29+
"",
30+
"",
31+
"abc",
32+
"def",
33+
"ghi",
34+
"jkl",
35+
"mno",
36+
"pqrs",
37+
"tuv",
38+
"wxyz"
39+
];
40+
41+
const list = [];
42+
backtrack(list, [], digits, 0, keys);
43+
return list;
44+
};

0 commit comments

Comments
 (0)