Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ainevsia committed Aug 4, 2023
1 parent 484a97f commit 8b08bab
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
5 changes: 3 additions & 2 deletions notes/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
- [669. 修剪二叉搜索树](./day23/lc669.md)
- [108. 将有序数组转换为二叉搜索树](./day23/lc108.md)
- [538. 把二叉搜索树转换为累加树](./day23/lc538.md)
- [day 24]
- [day 24](./day24.md)
- [77. 组合](./day24/lc77.md)
- [216. 组合总和 III](./day24/lc216.md)
- [day 26](./day26.md)
- [216. 组合总和 III](./day26/lc216.md)
46 changes: 46 additions & 0 deletions notes/src/day26/lc17.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 17. 电话号码的字母组合

## 题目描述

给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。

给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。

## 解题思路

```cpp
class Solution {
public:
const string a[10] = {
"", // 0
"", // 1
"abc", // 2
"def", // 3
"ghi", // 4
"jkl", // 5
"mno", // 6
"pqrs", // 7
"tuv", // 8
"wxyz", // 9
};
vector<string>res;
string cur;
string digits;
void b(int start) {
if(cur.size()==digits.size()){res.push_back(cur);return;}
string letters=a[digits[start]-'0'];
for(char c:letters){
cur.push_back(c);
b(start+1);
cur.pop_back();
}
}
vector<string> letterCombinations(string digits) {if(digits.size()==0)return vector<string>{};
this->digits=digits;b(0);return res;
}
};
```
## 学习感想
File renamed without changes.

0 comments on commit 8b08bab

Please sign in to comment.