🌍 English | 简体中文| 日本語 | Українською
High frequent interview LeetCode test for FaceBook, Linkedin, Amazon, Google. More importantly, the problems' solutions are provided in C/C++, Python and Java. Offer, Offer, Offer !
Note: Please raise an issue for any suggestions, corrections, and feedback.
- 2020年最新FLAMG面试频率最高的127道题.xlsx
- Google最常考的40道动态规划题.xlsx
- FaceBook高频题100道.xlsx
- CodeTop持续更新 https://codetop.cc/home
- 🔥 Top100
- 💠 Classification
- 📕 算法思维+算法模板
- 📂 面经C++/后端/算法
- 👥 Community
- 💖 Support
算法思维+算法模板
result = []
def backtrack(路径, 选择列表):
if 满足结束条件:
result.add(路径)
return
for 选择 in 选择列表:
做选择
backtrack(路径, 选择列表)
撤销选择
LeetCode 22. Generate Parentheses https://leetcode-cn.com/problems/generate-parentheses/
Given n
pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Example 1:
Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
Example 2:
Input: n = 1
Output: ["()"]
Constraints:
1 <= n <= 8
void backtrack(int n, int i, string& track) {
// i 代表当前的位置,共 2n 个位置
// 穷举到最后一个位置了,得到一个长度为 2n 组合
if (i == 2 * n) {
print(track);
return;
}
// 对于每个位置可以是左括号或者右括号两种选择
for choice in ['(', ')'] {
track.push(choice); // 做选择
// 穷举下一个位置
backtrack(n, i + 1, track);
track.pop(choice); // 撤销选择
}
}
See more -> 题解模板.md
- We have a discord server! This should be your first stop to talk with other Coding friends. Why don't you introduce yourself right now? Join the Coding channel in LeetCode4FLAG Discord
- You can also interact through GitHub issues. If there is any problem, or a change needs to be made to the repo, this is the place to start the conversation. Read more here.
- Subscribe to our Offical Account with WeChat.
专为求职面试中算法与数据结构的小伙伴,创了学习交流/刷题群(知识星球)!想要最快的提升算法与数据结构技能,和更多小伙伴一起来吧!进阶面试八股文,大厂面经
Donating to help me continue working on this project.
2021 © Charmve.