diff --git a/README.md b/README.md index 3e62e8aa..281df230 100755 --- a/README.md +++ b/README.md @@ -126,16 +126,16 @@ | | Easy | Medium | Hard | Total | |:--------:|:--------:|:--------:|:--------:|:--------:| -|Optimizing|33|37|27|97| +|Optimizing|33|36|27|96| |Accepted|**284**|**407**|**120**|**811**| |Total|506|1035|415|1956| -|Perfection Rate|88.4%|90.9%|77.5%|88.0%| +|Perfection Rate|88.4%|91.2%|77.5%|88.2%| |Completion Rate|56.1%|39.3%|28.9%|41.5%| |------------|----------------------------|----------------------------|----------------------------|----------------------------| ## 二. 目录 -以下已经收录了 714 道题的题解,还有 11 道题在尝试优化到 beats 100% +以下已经收录了 715 道题的题解,还有 11 道题在尝试优化到 beats 100% | No. | Title | Solution | Acceptance | Difficulty | Frequency | |:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:| @@ -254,7 +254,7 @@ |0113|Path Sum II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0113.Path-Sum-II)|51.4%|Medium|| |0114|Flatten Binary Tree to Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0114.Flatten-Binary-Tree-to-Linked-List)|54.5%|Medium|| |0115|Distinct Subsequences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0115.Distinct-Subsequences)|40.6%|Hard|| -|0116|Populating Next Right Pointers in Each Node||51.4%|Medium|| +|0116|Populating Next Right Pointers in Each Node|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node)|51.4%|Medium|| |0117|Populating Next Right Pointers in Each Node II||43.5%|Medium|| |0118|Pascal's Triangle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0118.Pascals-Triangle)|58.2%|Easy|| |0119|Pascal's Triangle II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0119.Pascals-Triangle-II)|53.8%|Easy|| @@ -514,7 +514,7 @@ |0373|Find K Pairs with Smallest Sums|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0373.Find-K-Pairs-with-Smallest-Sums)|39.0%|Medium|| |0374|Guess Number Higher or Lower|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0374.Guess-Number-Higher-or-Lower)|46.0%|Easy|| |0375|Guess Number Higher or Lower II||43.5%|Medium|| -|0376|Wiggle Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0376.Wiggle-Subsequence)|42.8%|Medium|| +|0376|Wiggle Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0376.Wiggle-Subsequence)|42.9%|Medium|| |0377|Combination Sum IV|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0377.Combination-Sum-IV)|47.5%|Medium|| |0378|Kth Smallest Element in a Sorted Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0378.Kth-Smallest-Element-in-a-Sorted-Matrix)|58.0%|Medium|| |0379|Design Phone Directory||49.3%|Medium|| @@ -633,7 +633,7 @@ |0492|Construct the Rectangle||51.3%|Easy|| |0493|Reverse Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0493.Reverse-Pairs)|28.2%|Hard|| |0494|Target Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0494.Target-Sum)|45.4%|Medium|| -|0495|Teemo Attacking||56.3%|Easy|| +|0495|Teemo Attacking||56.2%|Easy|| |0496|Next Greater Element I|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0496.Next-Greater-Element-I)|66.9%|Easy|| |0497|Random Point in Non-overlapping Rectangles|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0497.Random-Point-in-Non-overlapping-Rectangles)|39.1%|Medium|| |0498|Diagonal Traverse|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0498.Diagonal-Traverse)|52.0%|Medium|| @@ -859,7 +859,7 @@ |0718|Maximum Length of Repeated Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0718.Maximum-Length-of-Repeated-Subarray)|51.1%|Medium|| |0719|Find K-th Smallest Pair Distance|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0719.Find-K-th-Smallest-Pair-Distance)|33.2%|Hard|| |0720|Longest Word in Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0720.Longest-Word-in-Dictionary)|49.9%|Medium|| -|0721|Accounts Merge|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0721.Accounts-Merge)|53.3%|Medium|| +|0721|Accounts Merge|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0721.Accounts-Merge)|53.4%|Medium|| |0722|Remove Comments||36.9%|Medium|| |0723|Candy Crush||73.5%|Medium|| |0724|Find Pivot Index|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0724.Find-Pivot-Index)|48.0%|Easy|| @@ -982,7 +982,7 @@ |0841|Keys and Rooms|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0841.Keys-and-Rooms)|67.2%|Medium|| |0842|Split Array into Fibonacci Sequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0842.Split-Array-into-Fibonacci-Sequence)|37.2%|Medium|| |0843|Guess the Word||45.2%|Hard|| -|0844|Backspace String Compare|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0844.Backspace-String-Compare)|47.2%|Easy|| +|0844|Backspace String Compare|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0844.Backspace-String-Compare)|47.3%|Easy|| |0845|Longest Mountain in Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0845.Longest-Mountain-in-Array)|39.0%|Medium|| |0846|Hand of Straights||55.8%|Medium|| |0847|Shortest Path Visiting All Nodes||54.9%|Hard|| @@ -1406,7 +1406,7 @@ |1265|Print Immutable Linked List in Reverse||94.1%|Medium|| |1266|Minimum Time Visiting All Points|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1266.Minimum-Time-Visiting-All-Points)|79.2%|Easy|| |1267|Count Servers that Communicate||57.9%|Medium|| -|1268|Search Suggestions System|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1268.Search-Suggestions-System)|65.5%|Medium|| +|1268|Search Suggestions System|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1268.Search-Suggestions-System)|65.6%|Medium|| |1269|Number of Ways to Stay in the Same Place After Some Steps||43.3%|Hard|| |1270|All People Report to the Given Manager||88.3%|Medium|| |1271|Hexspeak||56.0%|Easy|| @@ -1688,7 +1688,7 @@ |1547|Minimum Cost to Cut a Stick||53.9%|Hard|| |1548|The Most Similar Path in a Graph||55.4%|Hard|| |1549|The Most Recent Orders for Each Product||67.5%|Medium|| -|1550|Three Consecutive Odds||64.0%|Easy|| +|1550|Three Consecutive Odds||64.1%|Easy|| |1551|Minimum Operations to Make Array Equal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1551.Minimum-Operations-to-Make-Array-Equal)|80.6%|Medium|| |1552|Magnetic Force Between Two Balls||51.2%|Medium|| |1553|Minimum Number of Days to Eat N Oranges||31.3%|Hard|| @@ -1744,7 +1744,7 @@ |1603|Design Parking System|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1603.Design-Parking-System)|86.6%|Easy|| |1604|Alert Using Same Key-Card Three or More Times in a One Hour Period||44.0%|Medium|| |1605|Find Valid Matrix Given Row and Column Sums||78.3%|Medium|| -|1606|Find Servers That Handled Most Number of Requests||38.7%|Hard|| +|1606|Find Servers That Handled Most Number of Requests||38.6%|Hard|| |1607|Sellers With No Sales||55.0%|Easy|| |1608|Special Array With X Elements Greater Than or Equal X|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X)|61.2%|Easy|| |1609|Even Odd Tree||52.2%|Medium|| @@ -1900,7 +1900,7 @@ |1759|Count Number of Homogenous Substrings||44.0%|Medium|| |1760|Minimum Limit of Balls in a Bag||54.5%|Medium|| |1761|Minimum Degree of a Connected Trio in a Graph||39.5%|Hard|| -|1762|Buildings With an Ocean View||81.3%|Medium|| +|1762|Buildings With an Ocean View||81.4%|Medium|| |1763|Longest Nice Substring||61.5%|Easy|| |1764|Form Array by Concatenating Subarrays of Another Array||53.1%|Medium|| |1765|Map of Highest Peak||57.6%|Medium|| @@ -1925,7 +1925,7 @@ |1784|Check if Binary String Has at Most One Segment of Ones||41.2%|Easy|| |1785|Minimum Elements to Add to Form a Given Sum||40.2%|Medium|| |1786|Number of Restricted Paths From First to Last Node||36.7%|Medium|| -|1787|Make the XOR of All Segments Equal to Zero||37.7%|Hard|| +|1787|Make the XOR of All Segments Equal to Zero||37.6%|Hard|| |1788|Maximize the Beauty of the Garden||67.0%|Hard|| |1789|Primary Department for Each Employee||79.8%|Easy|| |1790|Check if One String Swap Can Make Strings Equal||44.6%|Easy|| @@ -1942,14 +1942,14 @@ |1801|Number of Orders in the Backlog||44.6%|Medium|| |1802|Maximum Value at a Given Index in a Bounded Array||28.6%|Medium|| |1803|Count Pairs With XOR in a Range||45.4%|Hard|| -|1804|Implement Trie II (Prefix Tree)||58.4%|Medium|| +|1804|Implement Trie II (Prefix Tree)||58.3%|Medium|| |1805|Number of Different Integers in a String||34.9%|Easy|| |1806|Minimum Number of Operations to Reinitialize a Permutation||70.3%|Medium|| |1807|Evaluate the Bracket Pairs of a String||66.5%|Medium|| |1808|Maximize Number of Nice Divisors||28.5%|Hard|| |1809|Ad-Free Sessions||62.1%|Easy|| |1810|Minimum Path Cost in a Hidden Grid||54.1%|Medium|| -|1811|Find Interview Candidates||66.5%|Medium|| +|1811|Find Interview Candidates||66.4%|Medium|| |1812|Determine Color of a Chessboard Square||77.0%|Easy|| |1813|Sentence Similarity III||31.6%|Medium|| |1814|Count Nice Pairs in an Array||39.3%|Medium|| @@ -1981,7 +1981,7 @@ |1840|Maximum Building Height||34.5%|Hard|| |1841|League Statistics||61.8%|Medium|| |1842|Next Palindrome Using Same Digits||62.8%|Hard|| -|1843|Suspicious Bank Accounts||51.5%|Medium|| +|1843|Suspicious Bank Accounts||51.4%|Medium|| |1844|Replace All Digits with Characters||80.1%|Easy|| |1845|Seat Reservation Manager||56.4%|Medium|| |1846|Maximum Element After Decreasing and Rearranging|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1846.Maximum-Element-After-Decreasing-and-Rearranging)|55.4%|Medium|| @@ -2009,7 +2009,7 @@ |1868|Product of Two Run-Length Encoded Arrays||59.7%|Medium|| |1869|Longer Contiguous Segments of Ones than Zeros||59.5%|Easy|| |1870|Minimum Speed to Arrive on Time||32.9%|Medium|| -|1871|Jump Game VII||24.3%|Medium|| +|1871|Jump Game VII||24.2%|Medium|| |1872|Stone Game VIII||51.3%|Hard|| |1873|Calculate Special Bonus||90.9%|Easy|| |1874|Minimize Product Sum of Two Arrays||90.6%|Medium|| @@ -2026,7 +2026,7 @@ |1885|Count Pairs in Two Arrays||55.5%|Medium|| |1886|Determine Whether Matrix Can Be Obtained By Rotation||54.1%|Easy|| |1887|Reduction Operations to Make the Array Elements Equal||60.0%|Medium|| -|1888|Minimum Number of Flips to Make the Binary String Alternating||34.4%|Medium|| +|1888|Minimum Number of Flips to Make the Binary String Alternating||34.5%|Medium|| |1889|Minimum Space Wasted From Packaging||29.1%|Hard|| |1890|The Latest Login in 2020||85.9%|Easy|| |1891|Cutting Ribbons||51.3%|Medium|| @@ -2056,8 +2056,8 @@ |1915|Number of Wonderful Substrings||38.5%|Medium|| |1916|Count Ways to Build Rooms in an Ant Colony||50.1%|Hard|| |1917|Leetcodify Friends Recommendations||32.2%|Hard|| -|1918|Kth Smallest Subarray Sum||56.0%|Medium|| -|1919|Leetcodify Similar Friends||44.2%|Hard|| +|1918|Kth Smallest Subarray Sum||56.1%|Medium|| +|1919|Leetcodify Similar Friends||44.1%|Hard|| |1920|Build Array from Permutation||93.8%|Easy|| |1921|Eliminate Maximum Number of Monsters||37.4%|Medium|| |1922|Count Good Numbers||38.9%|Medium|| @@ -2087,9 +2087,9 @@ |1946|Largest Number After Mutating Substring||32.6%|Medium|| |1947|Maximum Compatibility Score Sum||56.9%|Medium|| |1948|Delete Duplicate Folders in System||61.9%|Hard|| -|1949|Strong Friendship||62.7%|Medium|| +|1949|Strong Friendship||62.6%|Medium|| |1950|Maximum of Minimum Values in All Subarrays||52.8%|Medium|| -|1951|All the Pairs With the Maximum Number of Common Followers||78.8%|Medium|| +|1951|All the Pairs With the Maximum Number of Common Followers||78.9%|Medium|| |1952|Three Divisors||55.8%|Easy|| |1953|Maximum Number of Weeks for Which You Can Work||33.5%|Medium|| |1954|Minimum Garden Perimeter to Collect Enough Apples||52.0%|Medium|| diff --git a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go index 9578b764..fdaa074c 100644 --- a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go +++ b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/116.Populating Next Right Pointers in Each Node.go @@ -12,12 +12,9 @@ func connect(root *Node) *Node { if root == nil { return root } - q := []*Node{root} - for len(q) > 0 { var p []*Node - // 遍历这一层的所有节点 for i, node := range q { if i+1 < len(q) { @@ -32,7 +29,6 @@ func connect(root *Node) *Node { } q = p } - return root } @@ -42,7 +38,6 @@ func connect2(root *Node) *Node { return nil } connectTwoNode(root.Left, root.Right) - return root } @@ -51,7 +46,6 @@ func connectTwoNode(node1, node2 *Node) { return } node1.Next = node2 - connectTwoNode(node1.Left, node1.Right) connectTwoNode(node2.Left, node2.Right) connectTwoNode(node1.Right, node2.Left) diff --git a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/README.md b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/README.md index b940e03f..f25539f4 100644 --- a/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/README.md +++ b/leetcode/0116.Populating-Next-Right-Pointers-in-Each-Node/README.md @@ -1,64 +1,86 @@ -# [116. Distinct Subsequences](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/) +# [116. Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/) ## 题目 -You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: -```go +You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: + +``` struct Node { int val; Node *left; Node *right; Node *next; } -``` -Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. -Initially, all next pointers are set to NULL. +``` + +Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. + +Initially, all next pointers are set to `NULL`. **Follow up:** + - You may only use constant extra space. - Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem. - **Example 1:** + + ``` Input: root = [1,2,3,4,5,6,7] Output: [1,#,2,3,#,4,5,6,7,#] -Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level. +Explanation:Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level. + ``` **Constraints:** -- The number of nodes in the given tree is less than 4096. -- -1000 <= node.val <= 1000 + +- The number of nodes in the given tree is less than `4096`. +- `1000 <= node.val <= 1000` ## 题目大意 -将二叉树的每一层节点都连接起来形成一个链表,每层的最后一个节点指向NULL. +给定一个 完美二叉树 ,其所有叶子节点都在同一层,每个父节点都有两个子节点。二叉树定义如下: +```jsx +struct Node { + int val; + Node *left; + Node *right; + Node *next; +} + +``` + +填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。初始状态下,所有 next 指针都被设置为 NULL。 ## 解题思路 -本质上是二叉树的层序遍历,基于广度优先搜索,将每层的节点放入队列,并遍历队列进行连接。 - +- 本质上是二叉树的层序遍历,基于广度优先搜索,将每层的节点放入队列,并遍历队列进行连接。 ## 代码 ```go package leetcode -// 解法一:迭代 +type Node struct { + Val int + Left *Node + Right *Node + Next *Node +} + +//解法一:迭代 func connect(root *Node) *Node { if root == nil { return root } - q := []*Node{root} - for len(q) > 0 { var p []*Node - + // 遍历这一层的所有节点 for i, node := range q { if i+1 < len(q) { node.Next = q[i+1] @@ -72,18 +94,15 @@ func connect(root *Node) *Node { } q = p } - return root } - // 解法二 递归 func connect2(root *Node) *Node { if root == nil { return nil } connectTwoNode(root.Left, root.Right) - return root } @@ -92,7 +111,6 @@ func connectTwoNode(node1, node2 *Node) { return } node1.Next = node2 - connectTwoNode(node1.Left, node1.Right) connectTwoNode(node2.Left, node2.Right) connectTwoNode(node1.Right, node2.Left) diff --git a/website/content/ChapterFour/0100~0199/0115.Distinct-Subsequences.md b/website/content/ChapterFour/0100~0199/0115.Distinct-Subsequences.md index cb88a997..b3baae4d 100644 --- a/website/content/ChapterFour/0100~0199/0115.Distinct-Subsequences.md +++ b/website/content/ChapterFour/0100~0199/0115.Distinct-Subsequences.md @@ -104,5 +104,5 @@ func numDistinct1(s, t string) int { ----------------------------------------------
diff --git a/website/content/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md b/website/content/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md new file mode 100644 index 00000000..95b54ea2 --- /dev/null +++ b/website/content/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md @@ -0,0 +1,125 @@ +# [116. Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/) + + +## 题目 + +You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: + +``` +struct Node { + int val; + Node *left; + Node *right; + Node *next; +} + +``` + +Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. + +Initially, all next pointers are set to `NULL`. + +**Follow up:** + +- You may only use constant extra space. +- Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem. + +**Example 1:** + + + +``` +Input: root = [1,2,3,4,5,6,7] +Output: [1,#,2,3,#,4,5,6,7,#] +Explanation:Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level. + +``` + +**Constraints:** + +- The number of nodes in the given tree is less than `4096`. +- `1000 <= node.val <= 1000` + +## 题目大意 + +给定一个 完美二叉树 ,其所有叶子节点都在同一层,每个父节点都有两个子节点。二叉树定义如下: + +```jsx +struct Node { + int val; + Node *left; + Node *right; + Node *next; +} + +``` + +填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。初始状态下,所有 next 指针都被设置为 NULL。 + +## 解题思路 + +- 本质上是二叉树的层序遍历,基于广度优先搜索,将每层的节点放入队列,并遍历队列进行连接。 + +## 代码 + +```go +package leetcode + +type Node struct { + Val int + Left *Node + Right *Node + Next *Node +} + +//解法一:迭代 +func connect(root *Node) *Node { + if root == nil { + return root + } + q := []*Node{root} + for len(q) > 0 { + var p []*Node + // 遍历这一层的所有节点 + for i, node := range q { + if i+1 < len(q) { + node.Next = q[i+1] + } + if node.Left != nil { + p = append(p, node.Left) + } + if node.Right != nil { + p = append(p, node.Right) + } + } + q = p + } + return root +} + +// 解法二 递归 +func connect2(root *Node) *Node { + if root == nil { + return nil + } + connectTwoNode(root.Left, root.Right) + return root +} + +func connectTwoNode(node1, node2 *Node) { + if node1 == nil || node2 == nil { + return + } + node1.Next = node2 + connectTwoNode(node1.Left, node1.Right) + connectTwoNode(node2.Left, node2.Right) + connectTwoNode(node1.Right, node2.Left) +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/0100~0199/0118.Pascals-Triangle.md b/website/content/ChapterFour/0100~0199/0118.Pascals-Triangle.md index 60efaae9..9dee8ab6 100644 --- a/website/content/ChapterFour/0100~0199/0118.Pascals-Triangle.md +++ b/website/content/ChapterFour/0100~0199/0118.Pascals-Triangle.md @@ -62,6 +62,6 @@ func generate(numRows int) [][]int { ---------------------------------------------- diff --git a/website/content/ChapterTwo/Array.md b/website/content/ChapterTwo/Array.md index 6ab45605..4c32020c 100644 --- a/website/content/ChapterTwo/Array.md +++ b/website/content/ChapterTwo/Array.md @@ -113,7 +113,7 @@ weight: 1 |0354|Russian Doll Envelopes|[Go]({{< relref "/ChapterFour/0300~0399/0354.Russian-Doll-Envelopes.md" >}})|Hard||||38.7%| |0368|Largest Divisible Subset|[Go]({{< relref "/ChapterFour/0300~0399/0368.Largest-Divisible-Subset.md" >}})|Medium||||38.8%| |0373|Find K Pairs with Smallest Sums|[Go]({{< relref "/ChapterFour/0300~0399/0373.Find-K-Pairs-with-Smallest-Sums.md" >}})|Medium||||39.0%| -|0376|Wiggle Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0376.Wiggle-Subsequence.md" >}})|Medium||||42.8%| +|0376|Wiggle Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0376.Wiggle-Subsequence.md" >}})|Medium||||42.9%| |0377|Combination Sum IV|[Go]({{< relref "/ChapterFour/0300~0399/0377.Combination-Sum-IV.md" >}})|Medium||||47.5%| |0378|Kth Smallest Element in a Sorted Matrix|[Go]({{< relref "/ChapterFour/0300~0399/0378.Kth-Smallest-Element-in-a-Sorted-Matrix.md" >}})|Medium||||58.0%| |0393|UTF-8 Validation|[Go]({{< relref "/ChapterFour/0300~0399/0393.UTF-8-Validation.md" >}})|Medium||||38.6%| @@ -194,7 +194,7 @@ weight: 1 |0718|Maximum Length of Repeated Subarray|[Go]({{< relref "/ChapterFour/0700~0799/0718.Maximum-Length-of-Repeated-Subarray.md" >}})|Medium||||51.1%| |0719|Find K-th Smallest Pair Distance|[Go]({{< relref "/ChapterFour/0700~0799/0719.Find-K-th-Smallest-Pair-Distance.md" >}})|Hard||||33.2%| |0720|Longest Word in Dictionary|[Go]({{< relref "/ChapterFour/0700~0799/0720.Longest-Word-in-Dictionary.md" >}})|Medium||||49.9%| -|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.3%| +|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.4%| |0724|Find Pivot Index|[Go]({{< relref "/ChapterFour/0700~0799/0724.Find-Pivot-Index.md" >}})|Easy||||48.0%| |0733|Flood Fill|[Go]({{< relref "/ChapterFour/0700~0799/0733.Flood-Fill.md" >}})|Easy||||56.3%| |0735|Asteroid Collision|[Go]({{< relref "/ChapterFour/0700~0799/0735.Asteroid-Collision.md" >}})|Medium||||43.7%| diff --git a/website/content/ChapterTwo/Breadth_First_Search.md b/website/content/ChapterTwo/Breadth_First_Search.md index 83de51fa..55b6a561 100644 --- a/website/content/ChapterTwo/Breadth_First_Search.md +++ b/website/content/ChapterTwo/Breadth_First_Search.md @@ -16,6 +16,7 @@ weight: 10 |0104|Maximum Depth of Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0104.Maximum-Depth-of-Binary-Tree.md" >}})|Easy||||69.4%| |0107|Binary Tree Level Order Traversal II|[Go]({{< relref "/ChapterFour/0100~0199/0107.Binary-Tree-Level-Order-Traversal-II.md" >}})|Medium| O(n)| O(1)||56.5%| |0111|Minimum Depth of Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}})|Easy| O(n)| O(1)||40.8%| +|0116|Populating Next Right Pointers in Each Node|[Go]({{< relref "/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md" >}})|Medium||||51.4%| |0126|Word Ladder II|[Go]({{< relref "/ChapterFour/0100~0199/0126.Word-Ladder-II.md" >}})|Hard| O(n)| O(n^2)|❤️|25.2%| |0127|Word Ladder|[Go]({{< relref "/ChapterFour/0100~0199/0127.Word-Ladder.md" >}})|Hard| O(n)| O(n)||33.1%| |0130|Surrounded Regions|[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})|Medium||||30.9%| @@ -48,7 +49,7 @@ weight: 10 |0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||33.3%| |0690|Employee Importance|[Go]({{< relref "/ChapterFour/0600~0699/0690.Employee-Importance.md" >}})|Easy||||60.6%| |0695|Max Area of Island|[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})|Medium||||67.0%| -|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.3%| +|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.4%| |0733|Flood Fill|[Go]({{< relref "/ChapterFour/0700~0799/0733.Flood-Fill.md" >}})|Easy||||56.3%| |0752|Open the Lock|[Go]({{< relref "/ChapterFour/0700~0799/0752.Open-the-Lock.md" >}})|Medium||||54.8%| |0756|Pyramid Transition Matrix|[Go]({{< relref "/ChapterFour/0700~0799/0756.Pyramid-Transition-Matrix.md" >}})|Medium||||56.0%| diff --git a/website/content/ChapterTwo/Depth_First_Search.md b/website/content/ChapterTwo/Depth_First_Search.md index a3143bca..2d5a7962 100644 --- a/website/content/ChapterTwo/Depth_First_Search.md +++ b/website/content/ChapterTwo/Depth_First_Search.md @@ -20,6 +20,7 @@ weight: 9 |0112|Path Sum|[Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}})|Easy| O(n)| O(1)||43.5%| |0113|Path Sum II|[Go]({{< relref "/ChapterFour/0100~0199/0113.Path-Sum-II.md" >}})|Medium| O(n)| O(1)||51.4%| |0114|Flatten Binary Tree to Linked List|[Go]({{< relref "/ChapterFour/0100~0199/0114.Flatten-Binary-Tree-to-Linked-List.md" >}})|Medium| O(n)| O(1)||54.5%| +|0116|Populating Next Right Pointers in Each Node|[Go]({{< relref "/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md" >}})|Medium||||51.4%| |0124|Binary Tree Maximum Path Sum|[Go]({{< relref "/ChapterFour/0100~0199/0124.Binary-Tree-Maximum-Path-Sum.md" >}})|Hard| O(n)| O(1)||36.3%| |0129|Sum Root to Leaf Numbers|[Go]({{< relref "/ChapterFour/0100~0199/0129.Sum-Root-to-Leaf-Numbers.md" >}})|Medium| O(n)| O(1)||52.7%| |0130|Surrounded Regions|[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})|Medium||||30.9%| @@ -68,7 +69,7 @@ weight: 9 |0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||33.3%| |0690|Employee Importance|[Go]({{< relref "/ChapterFour/0600~0699/0690.Employee-Importance.md" >}})|Easy||||60.6%| |0695|Max Area of Island|[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})|Medium||||67.0%| -|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.3%| +|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.4%| |0733|Flood Fill|[Go]({{< relref "/ChapterFour/0700~0799/0733.Flood-Fill.md" >}})|Easy||||56.3%| |0753|Cracking the Safe|[Go]({{< relref "/ChapterFour/0700~0799/0753.Cracking-the-Safe.md" >}})|Hard||||53.1%| |0756|Pyramid Transition Matrix|[Go]({{< relref "/ChapterFour/0700~0799/0756.Pyramid-Transition-Matrix.md" >}})|Medium||||56.0%| diff --git a/website/content/ChapterTwo/Dynamic_Programming.md b/website/content/ChapterTwo/Dynamic_Programming.md index 54a9da03..26b41ae4 100644 --- a/website/content/ChapterTwo/Dynamic_Programming.md +++ b/website/content/ChapterTwo/Dynamic_Programming.md @@ -48,7 +48,7 @@ weight: 7 |0354|Russian Doll Envelopes|[Go]({{< relref "/ChapterFour/0300~0399/0354.Russian-Doll-Envelopes.md" >}})|Hard||||38.7%| |0357|Count Numbers with Unique Digits|[Go]({{< relref "/ChapterFour/0300~0399/0357.Count-Numbers-with-Unique-Digits.md" >}})|Medium| O(1)| O(1)||49.5%| |0368|Largest Divisible Subset|[Go]({{< relref "/ChapterFour/0300~0399/0368.Largest-Divisible-Subset.md" >}})|Medium||||38.8%| -|0376|Wiggle Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0376.Wiggle-Subsequence.md" >}})|Medium||||42.8%| +|0376|Wiggle Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0376.Wiggle-Subsequence.md" >}})|Medium||||42.9%| |0377|Combination Sum IV|[Go]({{< relref "/ChapterFour/0300~0399/0377.Combination-Sum-IV.md" >}})|Medium||||47.5%| |0392|Is Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0392.Is-Subsequence.md" >}})|Easy| O(n)| O(1)||49.8%| |0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium||||33.8%| diff --git a/website/content/ChapterTwo/Stack.md b/website/content/ChapterTwo/Stack.md index 7266ebdb..d0cbe979 100644 --- a/website/content/ChapterTwo/Stack.md +++ b/website/content/ChapterTwo/Stack.md @@ -51,7 +51,7 @@ weight: 5 |0726|Number of Atoms|[Go]({{< relref "/ChapterFour/0700~0799/0726.Number-of-Atoms.md" >}})|Hard| O(n)| O(n) |❤️|51.2%| |0735|Asteroid Collision|[Go]({{< relref "/ChapterFour/0700~0799/0735.Asteroid-Collision.md" >}})|Medium| O(n)| O(n) ||43.7%| |0739|Daily Temperatures|[Go]({{< relref "/ChapterFour/0700~0799/0739.Daily-Temperatures.md" >}})|Medium| O(n)| O(n) ||65.6%| -|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||47.2%| +|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||47.3%| |0856|Score of Parentheses|[Go]({{< relref "/ChapterFour/0800~0899/0856.Score-of-Parentheses.md" >}})|Medium| O(n)| O(n)||65.2%| |0880|Decoded String at Index|[Go]({{< relref "/ChapterFour/0800~0899/0880.Decoded-String-at-Index.md" >}})|Medium| O(n)| O(n)||28.2%| |0895|Maximum Frequency Stack|[Go]({{< relref "/ChapterFour/0800~0899/0895.Maximum-Frequency-Stack.md" >}})|Hard| O(n)| O(n) ||63.8%| diff --git a/website/content/ChapterTwo/String.md b/website/content/ChapterTwo/String.md index be315b60..91f29641 100644 --- a/website/content/ChapterTwo/String.md +++ b/website/content/ChapterTwo/String.md @@ -87,7 +87,7 @@ weight: 2 |0696|Count Binary Substrings|[Go]({{< relref "/ChapterFour/0600~0699/0696.Count-Binary-Substrings.md" >}})|Easy||||61.8%| |0709|To Lower Case|[Go]({{< relref "/ChapterFour/0700~0799/0709.To-Lower-Case.md" >}})|Easy||||80.7%| |0720|Longest Word in Dictionary|[Go]({{< relref "/ChapterFour/0700~0799/0720.Longest-Word-in-Dictionary.md" >}})|Medium||||49.9%| -|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.3%| +|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||53.4%| |0726|Number of Atoms|[Go]({{< relref "/ChapterFour/0700~0799/0726.Number-of-Atoms.md" >}})|Hard||||51.2%| |0745|Prefix and Suffix Search|[Go]({{< relref "/ChapterFour/0700~0799/0745.Prefix-and-Suffix-Search.md" >}})|Hard||||35.3%| |0748|Shortest Completing Word|[Go]({{< relref "/ChapterFour/0700~0799/0748.Shortest-Completing-Word.md" >}})|Easy||||58.1%| @@ -108,7 +108,7 @@ weight: 2 |0838|Push Dominoes|[Go]({{< relref "/ChapterFour/0800~0899/0838.Push-Dominoes.md" >}})|Medium||||51.8%| |0839|Similar String Groups|[Go]({{< relref "/ChapterFour/0800~0899/0839.Similar-String-Groups.md" >}})|Hard||||43.1%| |0842|Split Array into Fibonacci Sequence|[Go]({{< relref "/ChapterFour/0800~0899/0842.Split-Array-into-Fibonacci-Sequence.md" >}})|Medium| O(n^2)| O(1)|❤️|37.2%| -|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy||||47.2%| +|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy||||47.3%| |0856|Score of Parentheses|[Go]({{< relref "/ChapterFour/0800~0899/0856.Score-of-Parentheses.md" >}})|Medium| O(n)| O(n)||65.2%| |0880|Decoded String at Index|[Go]({{< relref "/ChapterFour/0800~0899/0880.Decoded-String-at-Index.md" >}})|Medium||||28.2%| |0884|Uncommon Words from Two Sentences|[Go]({{< relref "/ChapterFour/0800~0899/0884.Uncommon-Words-from-Two-Sentences.md" >}})|Easy||||64.7%| diff --git a/website/content/ChapterTwo/Tree.md b/website/content/ChapterTwo/Tree.md index c99e650f..309da902 100644 --- a/website/content/ChapterTwo/Tree.md +++ b/website/content/ChapterTwo/Tree.md @@ -29,6 +29,7 @@ weight: 6 |0112|Path Sum|[Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}})|Easy| O(n)| O(1)||43.5%| |0113|Path Sum II|[Go]({{< relref "/ChapterFour/0100~0199/0113.Path-Sum-II.md" >}})|Medium| O(n)| O(1)||51.4%| |0114|Flatten Binary Tree to Linked List|[Go]({{< relref "/ChapterFour/0100~0199/0114.Flatten-Binary-Tree-to-Linked-List.md" >}})|Medium| O(n)| O(1)||54.5%| +|0116|Populating Next Right Pointers in Each Node|[Go]({{< relref "/ChapterFour/0100~0199/0116.Populating-Next-Right-Pointers-in-Each-Node.md" >}})|Medium||||51.4%| |0124|Binary Tree Maximum Path Sum|[Go]({{< relref "/ChapterFour/0100~0199/0124.Binary-Tree-Maximum-Path-Sum.md" >}})|Hard| O(n)| O(1)||36.3%| |0129|Sum Root to Leaf Numbers|[Go]({{< relref "/ChapterFour/0100~0199/0129.Sum-Root-to-Leaf-Numbers.md" >}})|Medium| O(n)| O(1)||52.7%| |0144|Binary Tree Preorder Traversal|[Go]({{< relref "/ChapterFour/0100~0199/0144.Binary-Tree-Preorder-Traversal.md" >}})|Easy| O(n)| O(1)||59.2%| diff --git a/website/content/ChapterTwo/Two_Pointers.md b/website/content/ChapterTwo/Two_Pointers.md index 7371490f..c4f99587 100644 --- a/website/content/ChapterTwo/Two_Pointers.md +++ b/website/content/ChapterTwo/Two_Pointers.md @@ -85,7 +85,7 @@ weight: 3 |0826|Most Profit Assigning Work|[Go]({{< relref "/ChapterFour/0800~0899/0826.Most-Profit-Assigning-Work.md" >}})|Medium| O(n log n)| O(n)||39.7%| |0832|Flipping an Image|[Go]({{< relref "/ChapterFour/0800~0899/0832.Flipping-an-Image.md" >}})|Easy||||78.8%| |0838|Push Dominoes|[Go]({{< relref "/ChapterFour/0800~0899/0838.Push-Dominoes.md" >}})|Medium| O(n)| O(n)||51.8%| -|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||47.2%| +|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||47.3%| |0845|Longest Mountain in Array|[Go]({{< relref "/ChapterFour/0800~0899/0845.Longest-Mountain-in-Array.md" >}})|Medium| O(n)| O(1) ||39.0%| |0876|Middle of the Linked List|[Go]({{< relref "/ChapterFour/0800~0899/0876.Middle-of-the-Linked-List.md" >}})|Easy||||69.7%| |0881|Boats to Save People|[Go]({{< relref "/ChapterFour/0800~0899/0881.Boats-to-Save-People.md" >}})|Medium| O(n log n)| O(1) ||49.3%| diff --git a/website/content/ChapterTwo/Union_Find.md b/website/content/ChapterTwo/Union_Find.md index 22e202f9..0f29e20b 100644 --- a/website/content/ChapterTwo/Union_Find.md +++ b/website/content/ChapterTwo/Union_Find.md @@ -27,7 +27,7 @@ weight: 16 |0684|Redundant Connection|[Go]({{< relref "/ChapterFour/0600~0699/0684.Redundant-Connection.md" >}})|Medium| O(n)| O(n)||60.0%| |0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard| O(n)| O(n)||33.3%| |0695|Max Area of Island|[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})|Medium||||67.0%| -|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium| O(n)| O(n)|❤️|53.3%| +|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium| O(n)| O(n)|❤️|53.4%| |0765|Couples Holding Hands|[Go]({{< relref "/ChapterFour/0700~0799/0765.Couples-Holding-Hands.md" >}})|Hard| O(n)| O(n)|❤️|56.0%| |0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard| O(n^2)| O(n)|❤️|57.7%| |0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.2%|