Skip to content

Commit

Permalink
feat: 每日一题2019-06-18参考答案
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhipeng committed Jun 19, 2019
1 parent 384ec43 commit fa65c42
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ The data structures mainly includes:

## Top Problems Progress

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

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



Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ leetcode 题解,记录自己的 leetcode 解题之路。

## Top题目进度

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

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

### leetcode 经典题目的解析
Expand Down
44 changes: 44 additions & 0 deletions daily/answers/17.letter-combinations-of-a-phone-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @lc app=leetcode id=17 lang=javascript
*
* [17] Letter Combinations of a Phone Number
*/
function backtrack(list, tempList, digits, start, keys) {
if (tempList.length === digits.length) {
return list.push(tempList.join(''));
}

for (let i = start; i < digits.length; i++) {
const chars = keys[digits[i]];
for (let j = 0; j < chars.length; j++) {
tempList.push(chars[j]);
backtrack(list, tempList, digits, i + 1, keys);
tempList.pop();
}
}
}
/**
* @param {string} digits
* @return {string[]}
*/
var letterCombinations = function(digits) {
if (digits.length === 0) return [];
// Input:Digit string "23"
// Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
const keys = [
"",
"",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz"
];

const list = [];
backtrack(list, [], digits, 0, keys);
return list;
};

0 comments on commit fa65c42

Please sign in to comment.