LeetCode4FLAG Save

🔥 🔥 High frequent interview LeetCode 100 for FaceBook,Linkedin,Amazon,Google,Microsoft. More importantly, the problems' solutions are provided,include C++, Python and Java.

Project README

LeetCode4FLAG  

🌍 English | 简体中文| 日本語 | Українською



CircleCI Version No. Code License Chinese Version

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 !

高频合集答题模板打卡群📕 Docs


Note: Please raise an issue for any suggestions, corrections, and feedback.


Buy Me A Coffee

Index


Top100

Company Level LeetCode Link Code ✅ AC
✂️ 74. Search a 2D Matrix 2021-09-30
🐼 1. Two Sum
📈 21. Merge Two Sorted Lists
🔎 107. Binary Tree Level Order Traversal II
👑 32. Longest Valid Parentheses
🎡 20. Valid Parentheses
🌄 200. Number of Islands
🐋 202. Happy Number
🐑 1120. Maximum Average Subtree
🐧 543. Diameter of Binary Tree
⛺ 297. Serialize and Deserialize Binary Tree
🌈 240. Search a 2D Matrix II
🚀 124. Binary Tree Maximum Path Sum
⛺ 297. Serialize and Deserialize Binary Tree
🌈 240. Search a 2D Matrix II
🚠 94. Binary Tree Inorder Traversal
⛵ 863. All Nodes Distance K in Binary Tree
📈 21. Merge Two Sorted Lists
🔎 107. Binary Tree Level Order Traversal II
👑 32. Longest Valid Parentheses
🎡 20. Valid Parentheses
🌄 200. Number of Islands
🐋 202. Happy Number
🐑 1120. Maximum Average Subtree
🐏 543. Diameter of Binary Tree
⛵ 494. Target Sum
🚁 938. Range Sum of BST
🚀 124. Binary Tree Maximum Path Sum
⛺ 173. Binary Search Tree Iterator
🌈 239. Sliding Window Maximum
🚠 833. Find And Replace in String
🌄 200. Number of Islands
🐠 67. Add Binary
🚩 90. Subsets II
🍐 17. Letter Combinations of a Phone Number
🚁 525. Contiguous Array
🎄 126. Word Ladder II
🎑 85. Maximal Rectangle
🎏 152. Maximum Product Subarray
🍋 678. Valid Parenthesis String
⛵ 245. Shortest Word Distance III
🚁 178. Rank Scores
⛺ 173. Binary Search Tree Iterator
🌈 239. Sliding Window Maximum
🎑 215. Kth Largest Element in an Array
🍋 678. Valid Parenthesis String
⛵ 236. Lowest Common Ancestor of a Binary Tree
🚁 剑指 Offer 51. 数组中的逆序对
⛺ 99. Recover Binary Search Tree
🌈 239. Sliding Window Maximum

Index

Buy Me A Coffee


Classification

Algorithm LeetCode Link Level Code ✅ AC
⛺ 568. Maximum Vacation Days ⭐⭐⭐⭐⭐
🌈 70. Climbing Stairs ⭐⭐
🚀 10. Regular Expression Matching ⭐⭐⭐⭐⭐
⛺ 198. House Robber ⭐⭐
🌈 139. Word Break ⭐⭐⭐
🎏 152. Maximum Product Subarray ⭐⭐⭐⭐⭐
🌈 91. Decode Ways ⭐⭐⭐⭐
🐼 72. Edit Distance ⭐⭐⭐⭐⭐
✂️ 4. Median of Two Sorted Arrays ⭐⭐⭐⭐⭐
🐼 23. Merge k Sorted Lists ⭐⭐⭐⭐⭐
📈 110. Balanced Binary Tree ⭐⭐
🚀 124. Binary Tree Maximum Path Sum ⭐⭐⭐⭐⭐
🐼 98. Validate Binary Search Tree ⭐⭐⭐
✂️ 153. Find Minimum in Rotated Sorted Array ⭐⭐⭐
🐼 33. Search in Rotated Sorted Array ⭐⭐⭐
📈 69. Sqrt(x) ⭐⭐
🔎 29. Divide Two Integers ⭐⭐⭐
🐼 162. Find Peak Element ⭐⭐⭐
✂️ 22. 括号生成 ⭐⭐⭐⭐⭐
🐼 89. 格雷编码 ⭐⭐⭐
📈 110. 平衡二叉树 ⭐⭐
📈 17. 电话号码的字母组合 ⭐⭐⭐
📈 46. 全排列 ⭐⭐⭐⭐
🔎 124. 二叉树中的最大路径和 ⭐⭐⭐⭐⭐
✂️ 215. 数组中的第K个最大元素 ⭐⭐⭐⭐
🐼 LintCode. 无序数组K小元素 ⭐⭐⭐
📈 629. K个逆序对数组 ⭐⭐⭐
🐼 剑指 Offer 51. 数组中的逆序对 ⭐⭐⭐
📈 327. 区间和的个数 ⭐⭐⭐⭐⭐
🔎 LintCode 399.Nuts & Bolts Problem-Nuts 和 Bolts 的问题 ⭐⭐⭐⭐
🐼 899. 有序队列 ⭐⭐⭐⭐⭐
🔎 376. 摆动序列 ⭐⭐⭐
✂️ 123. 买卖股票的最佳时机 III ⭐⭐⭐⭐
🐼 644. 最大子段和 II ⭐⭐⭐⭐
📈 102. 二叉树的层序遍历 ⭐⭐⭐
🐼 144. 二叉树的前序遍历 ⭐⭐⭐
📈 145. 二叉树的后序遍历 ⭐⭐⭐
🔎 987. 二叉树的垂序遍历 ⭐⭐⭐⭐⭐
🔎 257. 二叉树的所有路径 ⭐⭐
✂️ 剑指 Offer 48. 最长不含重复字符的子字符串 ⭐⭐⭐
🐼 11. 盛最多水的容器 ⭐⭐⭐
📈 42. 接雨水 ⭐⭐⭐ #双指针-two-pointers
📈 647. 回文子串 ⭐⭐⭐
✂️ 92. 反转链表 II ⭐⭐⭐
🔎 142. 环形链表 II ⭐⭐⭐⭐⭐
✂️ 127. 单词接龙 ⭐⭐⭐⭐
🐼 200. 岛屿数量 ⭐⭐⭐⭐⭐
📈 102. 二叉树的层序遍历 ⭐⭐⭐⭐⭐
📈 133. 克隆图 ⭐⭐⭐⭐
📈 107. 二叉树的层序遍历 II ⭐⭐⭐
🔎 199. 二叉树的右视图 ⭐⭐⭐
✂️ 111. 二叉树的最小深度 ⭐⭐⭐
🐼 面试题 05.01. 插入 ⭐⭐⭐⭐⭐
📈 126. 单词接龙 II ⭐⭐⭐
📈 131. 分割回文串 ⭐⭐⭐
📈 51. N 皇后 ⭐⭐⭐⭐
🔎 107. Binary Tree Level Order Traversal II ⭐⭐⭐

Index

算法思维+算法模板

回溯

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


Index

Community


Index

License

知识共享许可协议


Index

:rocket: 知识星球

专为求职面试中算法与数据结构的小伙伴,创了学习交流/刷题群(知识星球)!想要最快的提升算法与数据结构技能,和更多小伙伴一起来吧!进阶面试八股文,大厂面经

💖 Support this project

Donating to help me continue working on this project. BuymeaCoffee

Buy Me A Coffee

Donate with Paypal     Donate with AliPay | Donate with WeChat

2021 © Charmve.

Open Source Agenda is not affiliated with "LeetCode4FLAG" Project. README Source: Charmve/LeetCode4FLAG

Open Source Agenda Badge

Open Source Agenda Rating