Add solution 0665、0669、1423、1463、1579

This commit is contained in:
YDZ
2021-02-13 16:08:36 +08:00
parent 5e1c45cb84
commit c7862ae2bd
46 changed files with 1592 additions and 310 deletions

347
README.md
View File

@ -125,16 +125,16 @@
| | Easy | Medium | Hard | Total |
|:--------:|:--------:|:--------:|:--------:|:--------:|
|Optimizing|38|47|17|102|
|Optimizing|38|44|15|97|
|Accepted|**254**|**328**|**100**|**682**|
|Total|461|922|373|1756|
|Perfection Rate|85.0%|85.7%|83.0%|85.0%|
|Completion Rate|55.1%|35.6%|26.8%|38.8%|
|Total|462|922|373|1757|
|Perfection Rate|85.0%|86.6%|85.0%|85.8%|
|Completion Rate|55.0%|35.6%|26.8%|38.8%|
|------------|----------------------------|----------------------------|----------------------------|----------------------------|
## 二. 目录
以下已经收录了 580 道题的题解,还有 14 道题在尝试优化到 beats 100%
以下已经收录了 585 道题的题解,还有 13 道题在尝试优化到 beats 100%
| No. | Title | Solution | Acceptance | Difficulty | Frequency |
|:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|
@ -143,7 +143,7 @@
|0003|Longest Substring Without Repeating Characters|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0003.Longest-Substring-Without-Repeating-Characters)|31.4%|Medium||
|0004|Median of Two Sorted Arrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0004.Median-of-Two-Sorted-Arrays)|31.0%|Hard||
|0005|Longest Palindromic Substring||30.5%|Medium||
|0006|ZigZag Conversion||37.8%|Medium||
|0006|ZigZag Conversion||37.9%|Medium||
|0007|Reverse Integer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0007.Reverse-Integer)|25.9%|Easy||
|0008|String to Integer (atoi)||15.6%|Medium||
|0009|Palindrome Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0009.Palindrome-Number)|49.7%|Easy||
@ -165,7 +165,7 @@
|0025|Reverse Nodes in k-Group|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0025.Reverse-Nodes-in-k-Group)|44.7%|Hard||
|0026|Remove Duplicates from Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0026.Remove-Duplicates-from-Sorted-Array)|46.5%|Easy||
|0027|Remove Element|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0027.Remove-Element)|49.2%|Easy||
|0028|Implement strStr()|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0028.Implement-strStr())|35.1%|Easy||
|0028|Implement strStr()|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0028.Implement-strStr())|35.2%|Easy||
|0029|Divide Two Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0029.Divide-Two-Integers)|16.6%|Medium||
|0030|Substring with Concatenation of All Words|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0030.Substring-with-Concatenation-of-All-Words)|26.1%|Hard||
|0031|Next Permutation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0031.Next-Permutation)|33.8%|Medium||
@ -185,8 +185,8 @@
|0045|Jump Game II||31.4%|Hard||
|0046|Permutations|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0046.Permutations)|66.4%|Medium||
|0047|Permutations II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0047.Permutations-II)|49.3%|Medium||
|0048|Rotate Image|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0048.Rotate-Image)|59.7%|Medium||
|0049|Group Anagrams|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0049.Group-Anagrams)|59.1%|Medium||
|0048|Rotate Image|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0048.Rotate-Image)|59.8%|Medium||
|0049|Group Anagrams|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0049.Group-Anagrams)|59.2%|Medium||
|0050|Pow(x, n)|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0050.Pow(x,-n))|30.9%|Medium||
|0051|N-Queens|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0051.N-Queens)|49.5%|Hard||
|0052|N-Queens II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0052.N-Queens-II)|60.0%|Hard||
@ -245,7 +245,7 @@
|0105|Construct Binary Tree from Preorder and Inorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal)|51.6%|Medium||
|0106|Construct Binary Tree from Inorder and Postorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal)|49.5%|Medium||
|0107|Binary Tree Level Order Traversal II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0107.Binary-Tree-Level-Order-Traversal-II)|55.1%|Easy||
|0108|Convert Sorted Array to Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0108.Convert-Sorted-Array-to-Binary-Search-Tree)|60.2%|Easy||
|0108|Convert Sorted Array to Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0108.Convert-Sorted-Array-to-Binary-Search-Tree)|60.3%|Easy||
|0109|Convert Sorted List to Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0109.Convert-Sorted-List-to-Binary-Search-Tree)|50.1%|Medium||
|0110|Balanced Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0110.Balanced-Binary-Tree)|44.7%|Easy||
|0111|Minimum Depth of Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0111.Minimum-Depth-of-Binary-Tree)|39.4%|Easy||
@ -275,7 +275,7 @@
|0135|Candy||32.9%|Hard||
|0136|Single Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0136.Single-Number)|66.5%|Easy||
|0137|Single Number II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0137.Single-Number-II)|53.7%|Medium||
|0138|Copy List with Random Pointer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0138.Copy-List-with-Random-Pointer)|40.6%|Medium||
|0138|Copy List with Random Pointer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0138.Copy-List-with-Random-Pointer)|40.7%|Medium||
|0139|Word Break||41.6%|Medium||
|0140|Word Break II||34.5%|Hard||
|0141|Linked List Cycle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0141.Linked-List-Cycle)|42.8%|Easy||
@ -313,9 +313,9 @@
|0173|Binary Search Tree Iterator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0173.Binary-Search-Tree-Iterator)|60.0%|Medium||
|0174|Dungeon Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0174.Dungeon-Game)|33.2%|Hard||
|0175|Combine Two Tables||63.9%|Easy||
|0176|Second Highest Salary||33.1%|Easy||
|0176|Second Highest Salary||33.2%|Easy||
|0177|Nth Highest Salary||33.2%|Medium||
|0178|Rank Scores||49.8%|Medium||
|0178|Rank Scores||49.9%|Medium||
|0179|Largest Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0179.Largest-Number)|30.6%|Medium||
|0180|Consecutive Numbers||42.0%|Medium||
|0181|Employees Earning More Than Their Managers||60.1%|Easy||
@ -367,7 +367,7 @@
|0227|Basic Calculator II||38.5%|Medium||
|0228|Summary Ranges|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0228.Summary-Ranges)|42.3%|Easy||
|0229|Majority Element II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0229.Majority-Element-II)|38.7%|Medium||
|0230|Kth Smallest Element in a BST|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0230.Kth-Smallest-Element-in-a-BST)|62.4%|Medium||
|0230|Kth Smallest Element in a BST|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0230.Kth-Smallest-Element-in-a-BST)|62.5%|Medium||
|0231|Power of Two|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0231.Power-of-Two)|43.8%|Easy||
|0232|Implement Queue using Stacks|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0232.Implement-Queue-using-Stacks)|52.0%|Easy||
|0233|Number of Digit One||31.7%|Hard||
@ -389,7 +389,7 @@
|0249|Group Shifted Strings||57.9%|Medium||
|0250|Count Univalue Subtrees||53.3%|Medium||
|0251|Flatten 2D Vector||46.3%|Medium||
|0252|Meeting Rooms||55.3%|Easy||
|0252|Meeting Rooms||55.4%|Easy||
|0253|Meeting Rooms II||46.8%|Medium||
|0254|Factor Combinations||47.4%|Medium||
|0255|Verify Preorder Sequence in Binary Search Tree||46.1%|Medium||
@ -405,7 +405,7 @@
|0265|Paint House II||45.6%|Hard||
|0266|Palindrome Permutation||62.4%|Easy||
|0267|Palindrome Permutation II||37.4%|Medium||
|0268|Missing Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0268.Missing-Number)|53.7%|Easy||
|0268|Missing Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0268.Missing-Number)|53.8%|Easy||
|0269|Alien Dictionary||33.7%|Hard||
|0270|Closest Binary Search Tree Value||49.8%|Easy||
|0271|Encode and Decode Strings||32.7%|Medium||
@ -598,7 +598,7 @@
|0458|Poor Pigs||54.5%|Hard||
|0459|Repeated Substring Pattern||43.3%|Easy||
|0460|LFU Cache|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0460.LFU-Cache)|35.9%|Hard||
|0461|Hamming Distance|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0461.Hamming-Distance)|73.1%|Easy||
|0461|Hamming Distance|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0461.Hamming-Distance)|73.2%|Easy||
|0462|Minimum Moves to Equal Array Elements II||54.3%|Medium||
|0463|Island Perimeter|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0463.Island-Perimeter)|66.6%|Easy||
|0464|Can I Win||29.6%|Medium||
@ -629,7 +629,7 @@
|0489|Robot Room Cleaner||72.4%|Hard||
|0490|The Maze||52.7%|Medium||
|0491|Increasing Subsequences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0491.Increasing-Subsequences)|47.5%|Medium||
|0492|Construct the Rectangle||50.3%|Easy||
|0492|Construct the Rectangle||50.4%|Easy||
|0493|Reverse Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0493.Reverse-Pairs)|26.8%|Hard||
|0494|Target Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0494.Target-Sum)|45.8%|Medium||
|0495|Teemo Attacking||56.1%|Medium||
@ -698,7 +698,7 @@
|0558|Logical OR of Two Binary Grids Represented as Quad-Trees||45.5%|Medium||
|0559|Maximum Depth of N-ary Tree||69.5%|Easy||
|0560|Subarray Sum Equals K||43.8%|Medium||
|0561|Array Partition I|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0561.Array-Partition-I)|73.1%|Easy||
|0561|Array Partition I|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0561.Array-Partition-I)|73.2%|Easy||
|0562|Longest Line of Consecutive One in Matrix||46.2%|Medium||
|0563|Binary Tree Tilt|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0563.Binary-Tree-Tilt)|52.9%|Easy||
|0564|Find the Closest Palindrome||20.3%|Hard||
@ -713,7 +713,7 @@
|0573|Squirrel Simulation||54.4%|Medium||
|0574|Winning Candidate||51.7%|Medium||
|0575|Distribute Candies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0575.Distribute-Candies)|62.0%|Easy||
|0576|Out of Boundary Paths||35.8%|Medium||
|0576|Out of Boundary Paths||35.9%|Medium||
|0577|Employee Bonus||71.2%|Easy||
|0578|Get Highest Answer Rate Question||41.6%|Medium||
|0579|Find Cumulative Salary of an Employee||38.2%|Hard||
@ -723,7 +723,7 @@
|0583|Delete Operation for Two Strings||49.9%|Medium||
|0584|Find Customer Referee||73.9%|Easy||
|0585|Investments in 2016||56.7%|Medium||
|0586|Customer Placing the Largest Number of Orders||75.2%|Easy||
|0586|Customer Placing the Largest Number of Orders||75.3%|Easy||
|0587|Erect the Fence||36.4%|Hard||
|0588|Design In-Memory File System||46.6%|Hard||
|0589|N-ary Tree Preorder Traversal||73.3%|Easy||
@ -733,7 +733,7 @@
|0593|Valid Square||43.3%|Medium||
|0594|Longest Harmonious Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0594.Longest-Harmonious-Subsequence)|51.2%|Easy||
|0595|Big Countries||78.4%|Easy||
|0596|Classes More Than 5 Students||38.8%|Easy||
|0596|Classes More Than 5 Students||38.7%|Easy||
|0597|Friend Requests I: Overall Acceptance Rate||41.8%|Easy||
|0598|Range Addition II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0598.Range-Addition-II)|50.1%|Easy||
|0599|Minimum Index Sum of Two Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0599.Minimum-Index-Sum-of-Two-Lists)|51.6%|Easy||
@ -744,7 +744,7 @@
|0604|Design Compressed String Iterator||38.1%|Easy||
|0605|Can Place Flowers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0605.Can-Place-Flowers)|31.8%|Easy||
|0606|Construct String from Binary Tree||55.1%|Easy||
|0607|Sales Person||65.0%|Easy||
|0607|Sales Person||64.9%|Easy||
|0608|Tree Node||69.4%|Medium||
|0609|Find Duplicate File in System||61.0%|Medium||
|0610|Triangle Judgement||68.3%|Easy||
@ -752,7 +752,7 @@
|0612|Shortest Distance in a Plane||61.1%|Medium||
|0613|Shortest Distance in a Line||79.5%|Easy||
|0614|Second Degree Follower||32.4%|Medium||
|0615|Average Salary: Departments VS Company||52.0%|Hard||
|0615|Average Salary: Departments VS Company||52.1%|Hard||
|0616|Add Bold Tag in String||44.6%|Medium||
|0617|Merge Two Binary Trees||75.3%|Easy||
|0618|Students Report By Geography||59.5%|Hard||
@ -763,7 +763,7 @@
|0623|Add One Row to Tree||50.3%|Medium||
|0624|Maximum Distance in Arrays||39.5%|Medium||
|0625|Minimum Factorization||32.9%|Medium||
|0626|Exchange Seats||65.3%|Medium||
|0626|Exchange Seats||65.4%|Medium||
|0627|Swap Salary||77.5%|Easy||
|0628|Maximum Product of Three Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0628.Maximum-Product-of-Three-Numbers)|46.9%|Easy||
|0629|K Inverse Pairs Array||31.7%|Hard||
@ -798,19 +798,19 @@
|0658|Find K Closest Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0658.Find-K-Closest-Elements)|41.9%|Medium||
|0659|Split Array into Consecutive Subsequences||44.3%|Medium||
|0660|Remove 9||54.2%|Hard||
|0661|Image Smoother|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0661.Image-Smoother)|52.3%|Easy||
|0661|Image Smoother|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0661.Image-Smoother)|52.2%|Easy||
|0662|Maximum Width of Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0662.Maximum-Width-of-Binary-Tree)|39.9%|Medium||
|0663|Equal Tree Partition||39.7%|Medium||
|0664|Strange Printer||41.4%|Hard||
|0665|Non-decreasing Array||19.7%|Medium||
|0665|Non-decreasing Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0665.Non-decreasing-Array)|19.7%|Medium||
|0666|Path Sum IV||56.0%|Medium||
|0667|Beautiful Arrangement II||55.1%|Medium||
|0668|Kth Smallest Number in Multiplication Table|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0668.Kth-Smallest-Number-in-Multiplication-Table)|47.7%|Hard||
|0669|Trim a Binary Search Tree||64.5%|Medium||
|0669|Trim a Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0669.Trim-a-Binary-Search-Tree)|64.5%|Medium||
|0670|Maximum Swap||45.1%|Medium||
|0671|Second Minimum Node In a Binary Tree||42.8%|Easy||
|0672|Bulb Switcher II||51.1%|Medium||
|0673|Number of Longest Increasing Subsequence||38.5%|Medium||
|0673|Number of Longest Increasing Subsequence||38.4%|Medium||
|0674|Longest Continuous Increasing Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0674.Longest-Continuous-Increasing-Subsequence)|46.1%|Easy||
|0675|Cut Off Trees for Golf Event||35.3%|Hard||
|0676|Implement Magic Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0676.Implement-Magic-Dictionary)|55.2%|Medium||
@ -822,13 +822,13 @@
|0682|Baseball Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0682.Baseball-Game)|66.7%|Easy||
|0683|K Empty Slots||36.0%|Hard||
|0684|Redundant Connection|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0684.Redundant-Connection)|58.9%|Medium||
|0685|Redundant Connection II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0685.Redundant-Connection-II)|32.9%|Hard||
|0685|Redundant Connection II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0685.Redundant-Connection-II)|33.0%|Hard||
|0686|Repeated String Match||32.8%|Medium||
|0687|Longest Univalue Path||37.2%|Medium||
|0688|Knight Probability in Chessboard||50.0%|Medium||
|0689|Maximum Sum of 3 Non-Overlapping Subarrays||47.2%|Hard||
|0689|Maximum Sum of 3 Non-Overlapping Subarrays||47.1%|Hard||
|0690|Employee Importance||58.7%|Easy||
|0691|Stickers to Spell Word||44.4%|Hard||
|0691|Stickers to Spell Word||44.5%|Hard||
|0692|Top K Frequent Words||53.0%|Medium||
|0693|Binary Number with Alternating Bits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0693.Binary-Number-with-Alternating-Bits)|59.8%|Easy||
|0694|Number of Distinct Islands||57.8%|Medium||
@ -843,13 +843,13 @@
|0703|Kth Largest Element in a Stream|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0703.Kth-Largest-Element-in-a-Stream)|50.6%|Easy||
|0704|Binary Search|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0704.Binary-Search)|54.0%|Easy||
|0705|Design HashSet|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0705.Design-HashSet)|64.7%|Easy||
|0706|Design HashMap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0706.Design-HashMap)|62.7%|Easy||
|0706|Design HashMap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0706.Design-HashMap)|62.8%|Easy||
|0707|Design Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0707.Design-Linked-List)|25.8%|Medium||
|0708|Insert into a Sorted Circular Linked List||32.5%|Medium||
|0709|To Lower Case||80.0%|Easy||
|0710|Random Pick with Blacklist|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0710.Random-Pick-with-Blacklist)|32.7%|Hard||
|0711|Number of Distinct Islands II||49.2%|Hard||
|0712|Minimum ASCII Delete Sum for Two Strings||59.4%|Medium||
|0711|Number of Distinct Islands II||49.3%|Hard||
|0712|Minimum ASCII Delete Sum for Two Strings||59.5%|Medium||
|0713|Subarray Product Less Than K|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0713.Subarray-Product-Less-Than-K)|40.5%|Medium||
|0714|Best Time to Buy and Sell Stock with Transaction Fee|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0714.Best-Time-to-Buy-and-Sell-Stock-with-Transaction-Fee)|56.0%|Medium||
|0715|Range Module|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0715.Range-Module)|40.2%|Hard||
@ -860,7 +860,7 @@
|0720|Longest Word in Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0720.Longest-Word-in-Dictionary)|49.1%|Easy||
|0721|Accounts Merge|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0721.Accounts-Merge)|51.6%|Medium||
|0722|Remove Comments||36.0%|Medium||
|0723|Candy Crush||72.7%|Medium||
|0723|Candy Crush||72.6%|Medium||
|0724|Find Pivot Index|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0724.Find-Pivot-Index)|45.3%|Easy||
|0725|Split Linked List in Parts|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0725.Split-Linked-List-in-Parts)|52.9%|Medium||
|0726|Number of Atoms|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0726.Number-of-Atoms)|51.1%|Hard||
@ -886,7 +886,7 @@
|0746|Min Cost Climbing Stairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0746.Min-Cost-Climbing-Stairs)|50.9%|Easy||
|0747|Largest Number At Least Twice of Others||42.9%|Easy||
|0748|Shortest Completing Word|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0748.Shortest-Completing-Word)|57.5%|Easy||
|0749|Contain Virus||48.2%|Hard||
|0749|Contain Virus||48.3%|Hard||
|0750|Number Of Corner Rectangles||67.1%|Medium||
|0751|IP to CIDR||59.8%|Medium||
|0752|Open the Lock||52.8%|Medium||
@ -920,7 +920,7 @@
|0780|Reaching Points||30.3%|Hard||
|0781|Rabbits in Forest|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0781.Rabbits-in-Forest)|55.5%|Medium||
|0782|Transform to Chessboard||47.0%|Hard||
|0783|Minimum Distance Between BST Nodes||53.8%|Easy||
|0783|Minimum Distance Between BST Nodes||53.9%|Easy||
|0784|Letter Case Permutation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0784.Letter-Case-Permutation)|66.5%|Medium||
|0785|Is Graph Bipartite?|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0785.Is-Graph-Bipartite?)|48.3%|Medium||
|0786|K-th Smallest Prime Fraction|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0786.K-th-Smallest-Prime-Fraction)|42.3%|Hard||
@ -936,7 +936,7 @@
|0796|Rotate String||49.3%|Easy||
|0797|All Paths From Source to Target||78.5%|Medium||
|0798|Smallest Rotation with Highest Score||44.9%|Hard||
|0799|Champagne Tower||44.1%|Medium||
|0799|Champagne Tower||44.0%|Medium||
|0800|Similar RGB Color||62.2%|Easy||
|0801|Minimum Swaps To Make Sequences Increasing||39.0%|Medium||
|0802|Find Eventual Safe States|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0802.Find-Eventual-Safe-States)|49.8%|Medium||
@ -954,7 +954,7 @@
|0814|Binary Tree Pruning||72.7%|Medium||
|0815|Bus Routes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0815.Bus-Routes)|43.3%|Hard||
|0816|Ambiguous Coordinates||47.9%|Medium||
|0817|Linked List Components|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0817.Linked-List-Components)|57.7%|Medium||
|0817|Linked List Components|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0817.Linked-List-Components)|57.8%|Medium||
|0818|Race Car||39.8%|Hard||
|0819|Most Common Word|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0819.Most-Common-Word)|45.5%|Easy||
|0820|Short Encoding of Words||51.5%|Medium||
@ -962,7 +962,7 @@
|0822|Card Flipping Game||43.6%|Medium||
|0823|Binary Trees With Factors||36.5%|Medium||
|0824|Goat Latin||66.4%|Easy||
|0825|Friends Of Appropriate Ages||43.9%|Medium||
|0825|Friends Of Appropriate Ages||44.0%|Medium||
|0826|Most Profit Assigning Work|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0826.Most-Profit-Assigning-Work)|39.0%|Medium||
|0827|Making A Large Island||47.3%|Hard||
|0828|Count Unique Characters of All Substrings of a Given String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0828.Count-Unique-Characters-of-All-Substrings-of-a-Given-String)|46.8%|Hard||
@ -1007,7 +1007,7 @@
|0867|Transpose Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0867.Transpose-Matrix)|62.1%|Easy||
|0868|Binary Gap||60.9%|Easy||
|0869|Reordered Power of 2||54.1%|Medium||
|0870|Advantage Shuffle||46.7%|Medium||
|0870|Advantage Shuffle||46.8%|Medium||
|0871|Minimum Number of Refueling Stops||32.3%|Hard||
|0872|Leaf-Similar Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0872.Leaf-Similar-Trees)|64.6%|Easy||
|0873|Length of Longest Fibonacci Subsequence||48.1%|Medium||
@ -1021,7 +1021,7 @@
|0881|Boats to Save People|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0881.Boats-to-Save-People)|48.8%|Medium||
|0882|Reachable Nodes In Subdivided Graph||42.6%|Hard||
|0883|Projection Area of 3D Shapes||68.2%|Easy||
|0884|Uncommon Words from Two Sentences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0884.Uncommon-Words-from-Two-Sentences)|64.0%|Easy||
|0884|Uncommon Words from Two Sentences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0884.Uncommon-Words-from-Two-Sentences)|64.1%|Easy||
|0885|Spiral Matrix III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0885.Spiral-Matrix-III)|70.7%|Medium||
|0886|Possible Bipartition||45.1%|Medium||
|0887|Super Egg Drop|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0887.Super-Egg-Drop)|27.1%|Hard||
@ -1037,7 +1037,7 @@
|0897|Increasing Order Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0897.Increasing-Order-Search-Tree)|74.5%|Easy||
|0898|Bitwise ORs of Subarrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0898.Bitwise-ORs-of-Subarrays)|34.1%|Medium||
|0899|Orderly Queue||53.0%|Hard||
|0900|RLE Iterator||55.3%|Medium||
|0900|RLE Iterator||55.2%|Medium||
|0901|Online Stock Span|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0901.Online-Stock-Span)|61.3%|Medium||
|0902|Numbers At Most N Given Digit Set||36.1%|Hard||
|0903|Valid Permutations for DI Sequence||54.2%|Hard||
@ -1048,7 +1048,7 @@
|0908|Smallest Range I||66.4%|Easy||
|0909|Snakes and Ladders||39.2%|Medium||
|0910|Smallest Range II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0910.Smallest-Range-II)|31.3%|Medium||
|0911|Online Election|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0911.Online-Election)|51.2%|Medium||
|0911|Online Election|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0911.Online-Election)|51.3%|Medium||
|0912|Sort an Array||64.5%|Medium||
|0913|Cat and Mouse||34.7%|Hard||
|0914|X of a Kind in a Deck of Cards|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0914.X-of-a-Kind-in-a-Deck-of-Cards)|34.3%|Easy||
@ -1058,7 +1058,7 @@
|0918|Maximum Sum Circular Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0918.Maximum-Sum-Circular-Subarray)|34.2%|Medium||
|0919|Complete Binary Tree Inserter||58.8%|Medium||
|0920|Number of Music Playlists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0920.Number-of-Music-Playlists)|47.8%|Hard||
|0921|Minimum Add to Make Parentheses Valid|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0921.Minimum-Add-to-Make-Parentheses-Valid)|74.8%|Medium||
|0921|Minimum Add to Make Parentheses Valid|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0921.Minimum-Add-to-Make-Parentheses-Valid)|74.7%|Medium||
|0922|Sort Array By Parity II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0922.Sort-Array-By-Parity-II)|70.5%|Easy||
|0923|3Sum With Multiplicity|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0923.3Sum-With-Multiplicity)|36.2%|Medium||
|0924|Minimize Malware Spread|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0924.Minimize-Malware-Spread)|41.8%|Hard||
@ -1070,10 +1070,10 @@
|0930|Binary Subarrays With Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0930.Binary-Subarrays-With-Sum)|44.5%|Medium||
|0931|Minimum Falling Path Sum||63.3%|Medium||
|0932|Beautiful Array||61.1%|Medium||
|0933|Number of Recent Calls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0933.Number-of-Recent-Calls)|72.0%|Easy||
|0933|Number of Recent Calls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0933.Number-of-Recent-Calls)|72.1%|Easy||
|0934|Shortest Bridge||49.6%|Medium||
|0935|Knight Dialer||46.4%|Medium||
|0936|Stamping The Sequence||47.3%|Hard||
|0936|Stamping The Sequence||47.4%|Hard||
|0937|Reorder Data in Log Files||54.4%|Easy||
|0938|Range Sum of BST||83.0%|Easy||
|0939|Minimum Area Rectangle||51.9%|Medium||
@ -1103,7 +1103,7 @@
|0963|Minimum Area Rectangle II||51.8%|Medium||
|0964|Least Operators to Express Number||44.9%|Hard||
|0965|Univalued Binary Tree||67.8%|Easy||
|0966|Vowel Spellchecker||48.0%|Medium||
|0966|Vowel Spellchecker||47.9%|Medium||
|0967|Numbers With Same Consecutive Differences||44.7%|Medium||
|0968|Binary Tree Cameras|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0968.Binary-Tree-Cameras)|38.7%|Hard||
|0969|Pancake Sorting|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0969.Pancake-Sorting)|68.6%|Medium||
@ -1112,11 +1112,11 @@
|0972|Equal Rational Numbers||42.1%|Hard||
|0973|K Closest Points to Origin|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0973.K-Closest-Points-to-Origin)|64.6%|Medium||
|0974|Subarray Sums Divisible by K||50.8%|Medium||
|0975|Odd Even Jump||41.6%|Hard||
|0975|Odd Even Jump||41.5%|Hard||
|0976|Largest Perimeter Triangle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0976.Largest-Perimeter-Triangle)|58.5%|Easy||
|0977|Squares of a Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0977.Squares-of-a-Sorted-Array)|72.1%|Easy||
|0978|Longest Turbulent Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0978.Longest-Turbulent-Subarray)|46.6%|Medium||
|0979|Distribute Coins in Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0979.Distribute-Coins-in-Binary-Tree)|69.6%|Medium||
|0979|Distribute Coins in Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0979.Distribute-Coins-in-Binary-Tree)|69.7%|Medium||
|0980|Unique Paths III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0980.Unique-Paths-III)|77.2%|Hard||
|0981|Time Based Key-Value Store|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0981.Time-Based-Key-Value-Store)|54.1%|Medium||
|0982|Triples with Bitwise AND Equal To Zero||56.2%|Hard||
@ -1132,7 +1132,7 @@
|0992|Subarrays with K Different Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0992.Subarrays-with-K-Different-Integers)|50.6%|Hard||
|0993|Cousins in Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0993.Cousins-in-Binary-Tree)|52.3%|Easy||
|0994|Rotting Oranges||49.6%|Medium||
|0995|Minimum Number of K Consecutive Bit Flips|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0995.Minimum-Number-of-K-Consecutive-Bit-Flips)|49.7%|Hard||
|0995|Minimum Number of K Consecutive Bit Flips|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0995.Minimum-Number-of-K-Consecutive-Bit-Flips)|49.8%|Hard||
|0996|Number of Squareful Arrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0996.Number-of-Squareful-Arrays)|48.3%|Hard||
|0997|Find the Town Judge||49.8%|Easy||
|0998|Maximum Binary Tree II||63.8%|Medium||
@ -1158,7 +1158,7 @@
|1018|Binary Prefix Divisible By 5|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1018.Binary-Prefix-Divisible-By-5)|47.8%|Easy||
|1019|Next Greater Node In Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1019.Next-Greater-Node-In-Linked-List)|58.2%|Medium||
|1020|Number of Enclaves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1020.Number-of-Enclaves)|58.9%|Medium||
|1021|Remove Outermost Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1021.Remove-Outermost-Parentheses)|78.9%|Easy||
|1021|Remove Outermost Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1021.Remove-Outermost-Parentheses)|79.0%|Easy||
|1022|Sum of Root To Leaf Binary Numbers||71.5%|Easy||
|1023|Camelcase Matching||57.4%|Medium||
|1024|Video Stitching||49.0%|Medium||
@ -1172,13 +1172,13 @@
|1032|Stream of Characters||48.7%|Hard||
|1033|Moving Stones Until Consecutive||43.1%|Easy||
|1034|Coloring A Border||45.6%|Medium||
|1035|Uncrossed Lines||56.0%|Medium||
|1035|Uncrossed Lines||56.1%|Medium||
|1036|Escape a Large Maze||34.8%|Hard||
|1037|Valid Boomerang|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1037.Valid-Boomerang)|37.8%|Easy||
|1038|Binary Search Tree to Greater Sum Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1038.Binary-Search-Tree-to-Greater-Sum-Tree)|82.3%|Medium||
|1039|Minimum Score Triangulation of Polygon||50.1%|Medium||
|1040|Moving Stones Until Consecutive II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1040.Moving-Stones-Until-Consecutive-II)|54.1%|Medium||
|1041|Robot Bounded In Circle||55.0%|Medium||
|1041|Robot Bounded In Circle||54.9%|Medium||
|1042|Flower Planting With No Adjacent||48.7%|Medium||
|1043|Partition Array for Maximum Sum||66.8%|Medium||
|1044|Longest Duplicate Substring||31.5%|Hard||
@ -1207,8 +1207,8 @@
|1067|Digit Count in Range||41.3%|Hard||
|1068|Product Sales Analysis I||82.2%|Easy||
|1069|Product Sales Analysis II||83.3%|Easy||
|1070|Product Sales Analysis III||49.8%|Medium||
|1071|Greatest Common Divisor of Strings||51.3%|Easy||
|1070|Product Sales Analysis III||49.9%|Medium||
|1071|Greatest Common Divisor of Strings||51.2%|Easy||
|1072|Flip Columns For Maximum Number of Equal Rows||61.3%|Medium||
|1073|Adding Two Negabinary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1073.Adding-Two-Negabinary-Numbers)|34.8%|Medium||
|1074|Number of Submatrices That Sum to Target|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1074.Number-of-Submatrices-That-Sum-to-Target)|61.7%|Hard||
@ -1228,7 +1228,7 @@
|1088|Confusing Number II||45.4%|Hard||
|1089|Duplicate Zeros|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1089.Duplicate-Zeros)|51.9%|Easy||
|1090|Largest Values From Labels||60.0%|Medium||
|1091|Shortest Path in Binary Matrix||39.1%|Medium||
|1091|Shortest Path in Binary Matrix||39.3%|Medium||
|1092|Shortest Common Supersequence ||53.0%|Hard||
|1093|Statistics from a Large Sample|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1093.Statistics-from-a-Large-Sample)|49.3%|Medium||
|1094|Car Pooling||59.0%|Medium||
@ -1237,7 +1237,7 @@
|1097|Game Play Analysis V||56.2%|Hard||
|1098|Unpopular Books||45.4%|Medium||
|1099|Two Sum Less Than K||60.8%|Easy||
|1100|Find K-Length Substrings With No Repeated Characters||73.2%|Medium||
|1100|Find K-Length Substrings With No Repeated Characters||73.3%|Medium||
|1101|The Earliest Moment When Everyone Become Friends||67.9%|Medium||
|1102|Path With Maximum Minimum Value||50.4%|Medium||
|1103|Distribute Candies to People||63.5%|Easy||
@ -1248,7 +1248,7 @@
|1108|Defanging an IP Address|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1108.Defanging-an-IP-Address)|88.4%|Easy||
|1109|Corporate Flight Bookings||54.3%|Medium||
|1110|Delete Nodes And Return Forest|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1110.Delete-Nodes-And-Return-Forest)|67.7%|Medium||
|1111|Maximum Nesting Depth of Two Valid Parentheses Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1111.Maximum-Nesting-Depth-of-Two-Valid-Parentheses-Strings)|72.8%|Medium||
|1111|Maximum Nesting Depth of Two Valid Parentheses Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1111.Maximum-Nesting-Depth-of-Two-Valid-Parentheses-Strings)|72.7%|Medium||
|1112|Highest Grade For Each Student||71.9%|Medium||
|1113|Reported Posts||65.7%|Easy||
|1114|Print in Order||67.0%|Easy||
@ -1257,7 +1257,7 @@
|1117|Building H2O||53.1%|Medium||
|1118|Number of Days in a Month||57.4%|Easy||
|1119|Remove Vowels from a String||90.5%|Easy||
|1120|Maximum Average Subtree||63.5%|Medium||
|1120|Maximum Average Subtree||63.6%|Medium||
|1121|Divide Array Into Increasing Sequences||58.0%|Hard||
|1122|Relative Sort Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1122.Relative-Sort-Array)|68.1%|Easy||
|1123|Lowest Common Ancestor of Deepest Leaves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1123.Lowest-Common-Ancestor-of-Deepest-Leaves)|68.0%|Medium||
@ -1290,13 +1290,13 @@
|1150|Check If a Number Is Majority Element in a Sorted Array||57.5%|Easy||
|1151|Minimum Swaps to Group All 1's Together||58.5%|Medium||
|1152|Analyze User Website Visit Pattern||43.3%|Medium||
|1153|String Transforms Into Another String||36.0%|Hard||
|1153|String Transforms Into Another String||35.9%|Hard||
|1154|Day of the Year|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1154.Day-of-the-Year)|49.3%|Easy||
|1155|Number of Dice Rolls With Target Sum||47.6%|Medium||
|1156|Swap For Longest Repeated Character Substring||47.2%|Medium||
|1157|Online Majority Element In Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1157.Online-Majority-Element-In-Subarray)|39.7%|Hard||
|1157|Online Majority Element In Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1157.Online-Majority-Element-In-Subarray)|39.6%|Hard||
|1158|Market Analysis I||63.9%|Medium||
|1159|Market Analysis II||55.2%|Hard||
|1159|Market Analysis II||55.3%|Hard||
|1160|Find Words That Can Be Formed by Characters|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1160.Find-Words-That-Can-Be-Formed-by-Characters)|67.9%|Easy||
|1161|Maximum Level Sum of a Binary Tree||69.7%|Medium||
|1162|As Far from Land as Possible||45.2%|Medium||
@ -1306,17 +1306,17 @@
|1166|Design File System||58.5%|Medium||
|1167|Minimum Cost to Connect Sticks||64.4%|Medium||
|1168|Optimize Water Distribution in a Village||61.5%|Hard||
|1169|Invalid Transactions||31.2%|Medium||
|1170|Compare Strings by Frequency of the Smallest Character|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character)|59.5%|Medium||
|1169|Invalid Transactions||31.1%|Medium||
|1170|Compare Strings by Frequency of the Smallest Character|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character)|59.6%|Medium||
|1171|Remove Zero Sum Consecutive Nodes from Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1171.Remove-Zero-Sum-Consecutive-Nodes-from-Linked-List)|41.4%|Medium||
|1172|Dinner Plate Stacks||37.9%|Hard||
|1173|Immediate Food Delivery I||82.3%|Easy||
|1174|Immediate Food Delivery II||61.7%|Medium||
|1175|Prime Arrangements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1175.Prime-Arrangements)|52.0%|Easy||
|1176|Diet Plan Performance||54.1%|Easy||
|1176|Diet Plan Performance||54.0%|Easy||
|1177|Can Make Palindrome from Substring||36.1%|Medium||
|1178|Number of Valid Words for Each Puzzle||38.9%|Hard||
|1179|Reformat Department Table||81.9%|Easy||
|1179|Reformat Department Table||82.0%|Easy||
|1180|Count Substrings with Only One Distinct Letter||77.6%|Easy||
|1181|Before and After Puzzle||44.5%|Medium||
|1182|Shortest Distance to Target Color||53.4%|Medium||
@ -1332,7 +1332,7 @@
|1192|Critical Connections in a Network||50.0%|Hard||
|1193|Monthly Transactions I||69.3%|Medium||
|1194|Tournament Winners||51.9%|Hard||
|1195|Fizz Buzz Multithreaded||70.4%|Medium||
|1195|Fizz Buzz Multithreaded||70.5%|Medium||
|1196|How Many Apples Can You Put into the Basket||68.0%|Easy||
|1197|Minimum Knight Moves||37.2%|Medium||
|1198|Find Smallest Common Element in All Rows||75.2%|Medium||
@ -1341,7 +1341,7 @@
|1201|Ugly Number III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1201.Ugly-Number-III)|26.4%|Medium||
|1202|Smallest String With Swaps|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1202.Smallest-String-With-Swaps)|48.7%|Medium||
|1203|Sort Items by Groups Respecting Dependencies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1203.Sort-Items-by-Groups-Respecting-Dependencies)|48.9%|Hard||
|1204|Last Person to Fit in the Elevator||71.6%|Medium||
|1204|Last Person to Fit in the Elevator||71.7%|Medium||
|1205|Monthly Transactions II||45.8%|Medium||
|1206|Design Skiplist||59.1%|Hard||
|1207|Unique Number of Occurrences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1207.Unique-Number-of-Occurrences)|71.7%|Easy||
@ -1355,13 +1355,13 @@
|1215|Stepping Numbers||43.3%|Medium||
|1216|Valid Palindrome III||49.7%|Hard||
|1217|Minimum Cost to Move Chips to The Same Position|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1217.Minimum-Cost-to-Move-Chips-to-The-Same-Position)|71.2%|Easy||
|1218|Longest Arithmetic Subsequence of Given Difference||46.5%|Medium||
|1219|Path with Maximum Gold||65.6%|Medium||
|1218|Longest Arithmetic Subsequence of Given Difference||46.6%|Medium||
|1219|Path with Maximum Gold||65.7%|Medium||
|1220|Count Vowels Permutation||54.2%|Hard||
|1221|Split a String in Balanced Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1221.Split-a-String-in-Balanced-Strings)|84.1%|Easy||
|1222|Queens That Can Attack the King||69.4%|Medium||
|1223|Dice Roll Simulation||46.7%|Hard||
|1224|Maximum Equal Frequency||34.5%|Hard||
|1224|Maximum Equal Frequency||34.6%|Hard||
|1225|Report Contiguous Dates||62.6%|Hard||
|1226|The Dining Philosophers||59.8%|Medium||
|1227|Airplane Seat Assignment Probability||62.0%|Medium||
@ -1370,14 +1370,14 @@
|1230|Toss Strange Coins||50.0%|Medium||
|1231|Divide Chocolate||53.5%|Hard||
|1232|Check If It Is a Straight Line|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1232.Check-If-It-Is-a-Straight-Line)|43.7%|Easy||
|1233|Remove Sub-Folders from the Filesystem||61.9%|Medium||
|1233|Remove Sub-Folders from the Filesystem||62.0%|Medium||
|1234|Replace the Substring for Balanced String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1234.Replace-the-Substring-for-Balanced-String)|34.3%|Medium||
|1235|Maximum Profit in Job Scheduling|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1235.Maximum-Profit-in-Job-Scheduling)|47.4%|Hard||
|1236|Web Crawler||64.7%|Medium||
|1237|Find Positive Integer Solution for a Given Equation||69.6%|Medium||
|1238|Circular Permutation in Binary Representation||66.1%|Medium||
|1239|Maximum Length of a Concatenated String with Unique Characters||49.5%|Medium||
|1240|Tiling a Rectangle with the Fewest Squares||52.4%|Hard||
|1240|Tiling a Rectangle with the Fewest Squares||52.5%|Hard||
|1241|Number of Comments per Post||67.7%|Easy||
|1242|Web Crawler Multithreaded||47.7%|Medium||
|1243|Array Transformation||50.2%|Easy||
@ -1385,7 +1385,7 @@
|1245|Tree Diameter||61.2%|Medium||
|1246|Palindrome Removal||45.9%|Hard||
|1247|Minimum Swaps to Make Strings Equal||62.9%|Medium||
|1248|Count Number of Nice Subarrays||56.1%|Medium||
|1248|Count Number of Nice Subarrays||56.2%|Medium||
|1249|Minimum Remove to Make Valid Parentheses||63.7%|Medium||
|1250|Check If It Is a Good Array||56.2%|Hard||
|1251|Average Selling Price||82.5%|Easy||
@ -1431,7 +1431,7 @@
|1291|Sequential Digits||57.4%|Medium||
|1292|Maximum Side Length of a Square with Sum Less than or Equal to Threshold||50.5%|Medium||
|1293|Shortest Path in a Grid with Obstacles Elimination||43.0%|Hard||
|1294|Weather Type in Each Country||66.8%|Easy||
|1294|Weather Type in Each Country||66.7%|Easy||
|1295|Find Numbers with Even Number of Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1295.Find-Numbers-with-Even-Number-of-Digits)|79.2%|Easy||
|1296|Divide Array in Sets of K Consecutive Numbers||55.4%|Medium||
|1297|Maximum Number of Occurrences of a Substring||49.8%|Medium||
@ -1445,20 +1445,20 @@
|1305|All Elements in Two Binary Search Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1305.All-Elements-in-Two-Binary-Search-Trees)|77.8%|Medium||
|1306|Jump Game III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1306.Jump-Game-III)|62.6%|Medium||
|1307|Verbal Arithmetic Puzzle||36.9%|Hard||
|1308|Running Total for Different Genders||87.4%|Medium||
|1308|Running Total for Different Genders||87.3%|Medium||
|1309|Decrypt String from Alphabet to Integer Mapping||77.4%|Easy||
|1310|XOR Queries of a Subarray||69.2%|Medium||
|1311|Get Watched Videos by Your Friends||44.1%|Medium||
|1312|Minimum Insertion Steps to Make a String Palindrome||59.5%|Hard||
|1313|Decompress Run-Length Encoded List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1313.Decompress-Run-Length-Encoded-List)|85.4%|Easy||
|1314|Matrix Block Sum||73.6%|Medium||
|1314|Matrix Block Sum||73.7%|Medium||
|1315|Sum of Nodes with Even-Valued Grandparent||84.2%|Medium||
|1316|Distinct Echo Substrings||49.7%|Hard||
|1316|Distinct Echo Substrings||49.6%|Hard||
|1317|Convert Integer to the Sum of Two No-Zero Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1317.Convert-Integer-to-the-Sum-of-Two-No-Zero-Integers)|56.8%|Easy||
|1318|Minimum Flips to Make a OR b Equal to c||63.9%|Medium||
|1319|Number of Operations to Make Network Connected|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1319.Number-of-Operations-to-Make-Network-Connected)|55.3%|Medium||
|1319|Number of Operations to Make Network Connected|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1319.Number-of-Operations-to-Make-Network-Connected)|55.4%|Medium||
|1320|Minimum Distance to Type a Word Using Two Fingers||62.1%|Hard||
|1321|Restaurant Growth||71.0%|Medium||
|1321|Restaurant Growth||70.9%|Medium||
|1322|Ads Performance||58.0%|Easy||
|1323|Maximum 69 Number||78.0%|Easy||
|1324|Print Words Vertically||58.8%|Medium||
@ -1471,16 +1471,16 @@
|1331|Rank Transform of an Array||57.6%|Easy||
|1332|Remove Palindromic Subsequences||62.8%|Easy||
|1333|Filter Restaurants by Vegan-Friendly, Price and Distance||57.1%|Medium||
|1334|Find the City With the Smallest Number of Neighbors at a Threshold Distance||46.8%|Medium||
|1334|Find the City With the Smallest Number of Neighbors at a Threshold Distance||46.9%|Medium||
|1335|Minimum Difficulty of a Job Schedule||56.9%|Hard||
|1336|Number of Transactions per Visit||48.0%|Hard||
|1337|The K Weakest Rows in a Matrix||70.5%|Easy||
|1338|Reduce Array Size to The Half||67.6%|Medium||
|1338|Reduce Array Size to The Half||67.7%|Medium||
|1339|Maximum Product of Splitted Binary Tree||38.3%|Medium||
|1340|Jump Game V||59.2%|Hard||
|1341|Movie Rating||58.6%|Medium||
|1342|Number of Steps to Reduce a Number to Zero||85.8%|Easy||
|1343|Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold||64.7%|Medium||
|1342|Number of Steps to Reduce a Number to Zero||85.9%|Easy||
|1343|Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold||64.8%|Medium||
|1344|Angle Between Hands of a Clock||61.3%|Medium||
|1345|Jump Game IV||41.9%|Hard||
|1346|Check If N and Its Double Exist||36.3%|Easy||
@ -1495,15 +1495,15 @@
|1355|Activity Participants||74.3%|Medium||
|1356|Sort Integers by The Number of 1 Bits||69.7%|Easy||
|1357|Apply Discount Every n Orders||66.7%|Medium||
|1358|Number of Substrings Containing All Three Characters||60.5%|Medium||
|1358|Number of Substrings Containing All Three Characters||60.6%|Medium||
|1359|Count All Valid Pickup and Delivery Options||56.5%|Hard||
|1360|Number of Days Between Two Dates||46.9%|Easy||
|1360|Number of Days Between Two Dates||46.8%|Easy||
|1361|Validate Binary Tree Nodes||43.9%|Medium||
|1362|Closest Divisors||57.7%|Medium||
|1362|Closest Divisors||57.6%|Medium||
|1363|Largest Multiple of Three||34.0%|Hard||
|1364|Number of Trusted Contacts of a Customer||78.4%|Medium||
|1364|Number of Trusted Contacts of a Customer||78.5%|Medium||
|1365|How Many Numbers Are Smaller Than the Current Number||86.0%|Easy||
|1366|Rank Teams by Votes||55.1%|Medium||
|1366|Rank Teams by Votes||55.0%|Medium||
|1367|Linked List in Binary Tree||41.2%|Medium||
|1368|Minimum Cost to Make at Least One Valid Path in a Grid||57.0%|Hard||
|1369|Get the Second Most Recent Activity||68.7%|Hard||
@ -1516,7 +1516,7 @@
|1376|Time Needed to Inform All Employees||56.4%|Medium||
|1377|Frog Position After T Seconds||35.2%|Hard||
|1378|Replace Employee ID With The Unique Identifier||89.9%|Easy||
|1379|Find a Corresponding Node of a Binary Tree in a Clone of That Tree||84.7%|Medium||
|1379|Find a Corresponding Node of a Binary Tree in a Clone of That Tree||84.8%|Medium||
|1380|Lucky Numbers in a Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1380.Lucky-Numbers-in-a-Matrix)|70.8%|Easy||
|1381|Design a Stack With Increment Operation||76.1%|Medium||
|1382|Balance a Binary Search Tree||76.2%|Medium||
@ -1542,7 +1542,7 @@
|1402|Reducing Dishes||72.3%|Hard||
|1403|Minimum Subsequence in Non-Increasing Order||71.1%|Easy||
|1404|Number of Steps to Reduce a Number in Binary Representation to One||50.0%|Medium||
|1405|Longest Happy String||52.3%|Medium||
|1405|Longest Happy String||52.4%|Medium||
|1406|Stone Game III||57.3%|Hard||
|1407|Top Travellers||83.7%|Easy||
|1408|String Matching in an Array||62.7%|Easy||
@ -1552,7 +1552,7 @@
|1412|Find the Quiet Students in All Exams||65.1%|Hard||
|1413|Minimum Value to Get Positive Step by Step Sum||65.5%|Easy||
|1414|Find the Minimum Number of Fibonacci Numbers Whose Sum Is K||63.1%|Medium||
|1415|The k-th Lexicographical String of All Happy Strings of Length n||69.9%|Medium||
|1415|The k-th Lexicographical String of All Happy Strings of Length n||69.8%|Medium||
|1416|Restore The Array||36.3%|Hard||
|1417|Reformat The String||55.1%|Easy||
|1418|Display Table of Food Orders in a Restaurant||68.7%|Medium||
@ -1560,7 +1560,7 @@
|1420|Build Array Where You Can Find The Maximum Exactly K Comparisons||64.4%|Hard||
|1421|NPV Queries||81.9%|Medium||
|1422|Maximum Score After Splitting a String||56.0%|Easy||
|1423|Maximum Points You Can Obtain from Cards||46.6%|Medium||
|1423|Maximum Points You Can Obtain from Cards|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1423.Maximum-Points-You-Can-Obtain-from-Cards)|46.6%|Medium||
|1424|Diagonal Traverse II||45.9%|Medium||
|1425|Constrained Subsequence Sum||45.0%|Hard||
|1426|Counting Elements||59.1%|Easy||
@ -1571,8 +1571,8 @@
|1431|Kids With the Greatest Number of Candies||88.4%|Easy||
|1432|Max Difference You Can Get From Changing an Integer||42.9%|Medium||
|1433|Check If a String Can Break Another String||67.2%|Medium||
|1434|Number of Ways to Wear Different Hats to Each Other||39.4%|Hard||
|1435|Create a Session Bar Chart||77.7%|Easy||
|1434|Number of Ways to Wear Different Hats to Each Other||39.3%|Hard||
|1435|Create a Session Bar Chart||77.8%|Easy||
|1436|Destination City||77.0%|Easy||
|1437|Check If All 1's Are at Least Length K Places Away|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1437.Check-If-All-1's-Are-at-Least-Length-K-Places-Away)|62.7%|Easy||
|1438|Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit||44.2%|Medium||
@ -1592,18 +1592,18 @@
|1452|People Whose List of Favorite Companies Is Not a Subset of Another List||54.9%|Medium||
|1453|Maximum Number of Darts Inside of a Circular Dartboard||35.3%|Hard||
|1454|Active Users||38.8%|Medium||
|1455|Check If a Word Occurs As a Prefix of Any Word in a Sentence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1455.Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence)|64.5%|Easy||
|1455|Check If a Word Occurs As a Prefix of Any Word in a Sentence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1455.Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence)|64.4%|Easy||
|1456|Maximum Number of Vowels in a Substring of Given Length||54.5%|Medium||
|1457|Pseudo-Palindromic Paths in a Binary Tree||70.9%|Medium||
|1458|Max Dot Product of Two Subsequences||43.1%|Hard||
|1459|Rectangles Area||64.5%|Medium||
|1460|Make Two Arrays Equal by Reversing Sub-arrays||72.2%|Easy||
|1461|Check If a String Contains All Binary Codes of Size K||47.3%|Medium||
|1462|Course Schedule IV||44.6%|Medium||
|1463|Cherry Pickup II||69.3%|Hard||
|1462|Course Schedule IV||44.5%|Medium||
|1463|Cherry Pickup II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1463.Cherry-Pickup-II)|69.3%|Hard||
|1464|Maximum Product of Two Elements in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1464.Maximum-Product-of-Two-Elements-in-an-Array)|77.2%|Easy||
|1465|Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts||32.5%|Medium||
|1466|Reorder Routes to Make All Paths Lead to the City Zero||61.5%|Medium||
|1466|Reorder Routes to Make All Paths Lead to the City Zero||61.6%|Medium||
|1467|Probability of a Two Boxes Having The Same Number of Distinct Balls||61.0%|Hard||
|1468|Calculate Salaries||81.7%|Medium||
|1469|Find All The Lonely Nodes||80.6%|Easy||
@ -1631,7 +1631,7 @@
|1491|Average Salary Excluding the Minimum and Maximum Salary||68.7%|Easy||
|1492|The kth Factor of n||63.4%|Medium||
|1493|Longest Subarray of 1's After Deleting One Element||58.0%|Medium||
|1494|Parallel Courses II||31.4%|Hard||
|1494|Parallel Courses II||31.3%|Hard||
|1495|Friendly Movies Streamed Last Month||51.2%|Easy||
|1496|Path Crossing||55.3%|Easy||
|1497|Check If Array Pairs Are Divisible by k||40.5%|Medium||
@ -1651,9 +1651,9 @@
|1511|Customer Order Frequency||73.7%|Easy||
|1512|Number of Good Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1512.Number-of-Good-Pairs)|87.7%|Easy||
|1513|Number of Substrings With Only 1s||41.6%|Medium||
|1514|Path with Maximum Probability||39.9%|Medium||
|1514|Path with Maximum Probability||40.0%|Medium||
|1515|Best Position for a Service Centre||37.0%|Hard||
|1516|Move Sub-Tree of N-Ary Tree||63.1%|Hard||
|1516|Move Sub-Tree of N-Ary Tree||63.2%|Hard||
|1517|Find Users With Valid E-Mails||71.8%|Easy||
|1518|Water Bottles||60.6%|Easy||
|1519|Number of Nodes in the Sub-Tree With the Same Label||37.0%|Medium||
@ -1664,13 +1664,13 @@
|1524|Number of Sub-arrays With Odd Sum||39.9%|Medium||
|1525|Number of Good Ways to Split a String||66.4%|Medium||
|1526|Minimum Number of Increments on Subarrays to Form a Target Array||60.0%|Hard||
|1527|Patients With a Condition||69.4%|Easy||
|1527|Patients With a Condition||69.2%|Easy||
|1528|Shuffle String||85.8%|Easy||
|1529|Bulb Switcher IV||70.9%|Medium||
|1530|Number of Good Leaf Nodes Pairs||56.1%|Medium||
|1531|String Compression II||33.8%|Hard||
|1532|The Most Recent Three Orders||73.0%|Medium||
|1533|Find the Index of the Large Integer||54.6%|Medium||
|1532|The Most Recent Three Orders||72.9%|Medium||
|1533|Find the Index of the Large Integer||54.7%|Medium||
|1534|Count Good Triplets||80.4%|Easy||
|1535|Find the Winner of an Array Game||47.4%|Medium||
|1536|Minimum Swaps to Arrange a Binary Grid||43.4%|Medium||
@ -1694,7 +1694,7 @@
|1554|Strings Differ by One Character||63.4%|Medium||
|1555|Bank Account Summary||52.7%|Medium||
|1556|Thousand Separator||57.8%|Easy||
|1557|Minimum Number of Vertices to Reach All Nodes||75.6%|Medium||
|1557|Minimum Number of Vertices to Reach All Nodes||75.5%|Medium||
|1558|Minimum Numbers of Function Calls to Make Target Array||63.5%|Medium||
|1559|Detect Cycles in 2D Grid||44.3%|Hard||
|1560|Most Visited Sector in a Circular Track||56.9%|Easy||
@ -1702,7 +1702,7 @@
|1562|Find Latest Group of Size M||39.5%|Medium||
|1563|Stone Game V||40.0%|Hard||
|1564|Put Boxes Into the Warehouse I||65.8%|Medium||
|1565|Unique Orders and Customers Per Month||82.8%|Easy||
|1565|Unique Orders and Customers Per Month||82.9%|Easy||
|1566|Detect Pattern of Length M Repeated K or More Times||42.4%|Easy||
|1567|Maximum Length of Subarray With Positive Product||36.7%|Medium||
|1568|Minimum Number of Days to Disconnect Island||50.2%|Hard||
@ -1713,21 +1713,21 @@
|1573|Number of Ways to Split a String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1573.Number-of-Ways-to-Split-a-String)|31.0%|Medium||
|1574|Shortest Subarray to be Removed to Make Array Sorted||33.3%|Medium||
|1575|Count All Possible Routes||57.3%|Hard||
|1576|Replace All ?'s to Avoid Consecutive Repeating Characters||48.4%|Easy||
|1576|Replace All ?'s to Avoid Consecutive Repeating Characters||48.3%|Easy||
|1577|Number of Ways Where Square of Number Is Equal to Product of Two Numbers||37.4%|Medium||
|1578|Minimum Deletion Cost to Avoid Repeating Letters||60.4%|Medium||
|1579|Remove Max Number of Edges to Keep Graph Fully Traversable||46.2%|Hard||
|1579|Remove Max Number of Edges to Keep Graph Fully Traversable|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable)|46.3%|Hard||
|1580|Put Boxes Into the Warehouse II||61.8%|Medium||
|1581|Customer Who Visited but Did Not Make Any Transactions||89.8%|Easy||
|1581|Customer Who Visited but Did Not Make Any Transactions||89.6%|Easy||
|1582|Special Positions in a Binary Matrix||64.3%|Easy||
|1583|Count Unhappy Friends||54.3%|Medium||
|1584|Min Cost to Connect All Points||51.6%|Medium||
|1585|Check If String Is Transformable With Substring Sort Operations||48.2%|Hard||
|1586|Binary Search Tree Iterator II||66.5%|Medium||
|1587|Bank Account Summary II||89.9%|Easy||
|1587|Bank Account Summary II||90.0%|Easy||
|1588|Sum of All Odd Length Subarrays||82.0%|Easy||
|1589|Maximum Sum Obtained of Any Permutation||34.8%|Medium||
|1590|Make Sum Divisible by P||27.1%|Medium||
|1590|Make Sum Divisible by P||27.0%|Medium||
|1591|Strange Printer II||55.1%|Hard||
|1592|Rearrange Spaces Between Words||43.8%|Easy||
|1593|Split a String Into the Max Number of Unique Substrings||48.9%|Medium||
@ -1743,157 +1743,158 @@
|1603|Design Parking System||86.5%|Easy||
|1604|Alert Using Same Key-Card Three or More Times in a One Hour Period||42.3%|Medium||
|1605|Find Valid Matrix Given Row and Column Sums||77.2%|Medium||
|1606|Find Servers That Handled Most Number of Requests||37.0%|Hard||
|1607|Sellers With No Sales||55.5%|Easy||
|1606|Find Servers That Handled Most Number of Requests||36.9%|Hard||
|1607|Sellers With No Sales||55.6%|Easy||
|1608|Special Array With X Elements Greater Than or Equal X||61.7%|Easy||
|1609|Even Odd Tree||52.8%|Medium||
|1610|Maximum Number of Visible Points||29.2%|Hard||
|1611|Minimum One Bit Operations to Make Integers Zero||57.6%|Hard||
|1612|Check If Two Expression Trees are Equivalent||69.9%|Medium||
|1611|Minimum One Bit Operations to Make Integers Zero||57.5%|Hard||
|1612|Check If Two Expression Trees are Equivalent||69.8%|Medium||
|1613|Find the Missing IDs||73.5%|Medium||
|1614|Maximum Nesting Depth of the Parentheses||83.1%|Easy||
|1615|Maximal Network Rank||51.9%|Medium||
|1616|Split Two Strings to Make Palindrome||36.2%|Medium||
|1617|Count Subtrees With Max Distance Between Cities||63.7%|Hard||
|1617|Count Subtrees With Max Distance Between Cities||63.8%|Hard||
|1618|Maximum Font to Fit a Sentence in a Screen||57.4%|Medium||
|1619|Mean of Array After Removing Some Elements||65.2%|Easy||
|1620|Coordinate With Maximum Network Quality||37.1%|Medium||
|1621|Number of Sets of K Non-Overlapping Line Segments||41.0%|Medium||
|1622|Fancy Sequence||15.2%|Hard||
|1623|All Valid Triplets That Can Represent a Country||89.0%|Easy||
|1622|Fancy Sequence||15.3%|Hard||
|1623|All Valid Triplets That Can Represent a Country||88.9%|Easy||
|1624|Largest Substring Between Two Equal Characters||58.9%|Easy||
|1625|Lexicographically Smallest String After Applying Operations||63.8%|Medium||
|1626|Best Team With No Conflicts||37.7%|Medium||
|1627|Graph Connectivity With Threshold||38.6%|Hard||
|1628|Design an Expression Tree With Evaluate Function||80.4%|Medium||
|1629|Slowest Key||59.2%|Easy||
|1630|Arithmetic Subarrays||77.6%|Medium||
|1630|Arithmetic Subarrays||77.7%|Medium||
|1631|Path With Minimum Effort||50.1%|Medium||
|1632|Rank Transform of a Matrix||30.7%|Hard||
|1632|Rank Transform of a Matrix||30.6%|Hard||
|1633|Percentage of Users Attended a Contest||72.0%|Easy||
|1634|Add Two Polynomials Represented as Linked Lists||55.7%|Medium||
|1634|Add Two Polynomials Represented as Linked Lists||55.6%|Medium||
|1635|Hopper Company Queries I||56.3%|Hard||
|1636|Sort Array by Increasing Frequency||66.8%|Easy||
|1637|Widest Vertical Area Between Two Points Containing No Points||83.9%|Medium||
|1638|Count Substrings That Differ by One Character||68.8%|Medium||
|1638|Count Substrings That Differ by One Character||68.9%|Medium||
|1639|Number of Ways to Form a Target String Given a Dictionary||39.5%|Hard||
|1640|Check Array Formation Through Concatenation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1640.Check-Array-Formation-Through-Concatenation)|60.2%|Easy||
|1641|Count Sorted Vowel Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1641.Count-Sorted-Vowel-Strings)|76.9%|Medium||
|1642|Furthest Building You Can Reach||50.6%|Medium||
|1642|Furthest Building You Can Reach||50.5%|Medium||
|1643|Kth Smallest Instructions||43.4%|Hard||
|1644|Lowest Common Ancestor of a Binary Tree II||57.2%|Medium||
|1645|Hopper Company Queries II||39.7%|Hard||
|1645|Hopper Company Queries II||39.6%|Hard||
|1646|Get Maximum in Generated Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1646.Get-Maximum-in-Generated-Array)|53.5%|Easy||
|1647|Minimum Deletions to Make Character Frequencies Unique|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique)|54.5%|Medium||
|1648|Sell Diminishing-Valued Colored Balls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1648.Sell-Diminishing-Valued-Colored-Balls)|30.8%|Medium||
|1649|Create Sorted Array through Instructions|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1649.Create-Sorted-Array-through-Instructions)|36.3%|Hard||
|1650|Lowest Common Ancestor of a Binary Tree III||76.9%|Medium||
|1651|Hopper Company Queries III||67.4%|Hard||
|1652|Defuse the Bomb|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1652.Defuse-the-Bomb)|62.9%|Easy||
|1650|Lowest Common Ancestor of a Binary Tree III||77.0%|Medium||
|1651|Hopper Company Queries III||67.5%|Hard||
|1652|Defuse the Bomb|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1652.Defuse-the-Bomb)|63.0%|Easy||
|1653|Minimum Deletions to Make String Balanced|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1653.Minimum-Deletions-to-Make-String-Balanced)|50.6%|Medium||
|1654|Minimum Jumps to Reach Home|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1654.Minimum-Jumps-to-Reach-Home)|26.1%|Medium||
|1655|Distribute Repeating Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1655.Distribute-Repeating-Integers)|40.4%|Hard||
|1655|Distribute Repeating Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1655.Distribute-Repeating-Integers)|40.3%|Hard||
|1656|Design an Ordered Stream|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1656.Design-an-Ordered-Stream)|82.2%|Easy||
|1657|Determine if Two Strings Are Close|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1657.Determine-if-Two-Strings-Are-Close)|55.4%|Medium||
|1658|Minimum Operations to Reduce X to Zero|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1658.Minimum-Operations-to-Reduce-X-to-Zero)|33.4%|Medium||
|1659|Maximize Grid Happiness|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1659.Maximize-Grid-Happiness)|35.3%|Hard||
|1660|Correct a Binary Tree||77.9%|Medium||
|1661|Average Time of Process per Machine||79.2%|Easy||
|1660|Correct a Binary Tree||77.7%|Medium||
|1661|Average Time of Process per Machine||79.4%|Easy||
|1662|Check If Two String Arrays are Equivalent|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1662.Check-If-Two-String-Arrays-are-Equivalent)|83.3%|Easy||
|1663|Smallest String With A Given Numeric Value|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1663.Smallest-String-With-A-Given-Numeric-Value)|64.3%|Medium||
|1664|Ways to Make a Fair Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1664.Ways-to-Make-a-Fair-Array)|60.6%|Medium||
|1665|Minimum Initial Energy to Finish Tasks|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1665.Minimum-Initial-Energy-to-Finish-Tasks)|66.5%|Hard||
|1666|Change the Root of a Binary Tree||69.5%|Medium||
|1665|Minimum Initial Energy to Finish Tasks|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1665.Minimum-Initial-Energy-to-Finish-Tasks)|66.4%|Hard||
|1666|Change the Root of a Binary Tree||69.4%|Medium||
|1667|Fix Names in a Table||63.5%|Easy||
|1668|Maximum Repeating Substring|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1668.Maximum-Repeating-Substring)|38.5%|Easy||
|1669|Merge In Between Linked Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1669.Merge-In-Between-Linked-Lists)|77.1%|Medium||
|1670|Design Front Middle Back Queue|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1670.Design-Front-Middle-Back-Queue)|54.6%|Medium||
|1669|Merge In Between Linked Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1669.Merge-In-Between-Linked-Lists)|77.0%|Medium||
|1670|Design Front Middle Back Queue|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1670.Design-Front-Middle-Back-Queue)|54.5%|Medium||
|1671|Minimum Number of Removals to Make Mountain Array||45.5%|Hard||
|1672|Richest Customer Wealth|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1672.Richest-Customer-Wealth)|88.4%|Easy||
|1673|Find the Most Competitive Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1673.Find-the-Most-Competitive-Subsequence)|45.2%|Medium||
|1674|Minimum Moves to Make Array Complementary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1674.Minimum-Moves-to-Make-Array-Complementary)|34.7%|Medium||
|1675|Minimize Deviation in Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1675.Minimize-Deviation-in-Array)|48.5%|Hard||
|1676|Lowest Common Ancestor of a Binary Tree IV||78.5%|Medium||
|1676|Lowest Common Ancestor of a Binary Tree IV||78.6%|Medium||
|1677|Product's Worth Over Invoices||73.8%|Easy||
|1678|Goal Parser Interpretation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1678.Goal-Parser-Interpretation)|85.7%|Easy||
|1679|Max Number of K-Sum Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1679.Max-Number-of-K-Sum-Pairs)|54.2%|Medium||
|1680|Concatenation of Consecutive Binary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1680.Concatenation-of-Consecutive-Binary-Numbers)|52.4%|Medium||
|1681|Minimum Incompatibility|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1681.Minimum-Incompatibility)|35.4%|Hard||
|1682|Longest Palindromic Subsequence II||50.6%|Medium||
|1682|Longest Palindromic Subsequence II||50.5%|Medium||
|1683|Invalid Tweets||91.1%|Easy||
|1684|Count the Number of Consistent Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1684.Count-the-Number-of-Consistent-Strings)|83.3%|Easy||
|1684|Count the Number of Consistent Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1684.Count-the-Number-of-Consistent-Strings)|83.2%|Easy||
|1685|Sum of Absolute Differences in a Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1685.Sum-of-Absolute-Differences-in-a-Sorted-Array)|62.9%|Medium||
|1686|Stone Game VI||49.0%|Medium||
|1687|Delivering Boxes from Storage to Ports||34.6%|Hard||
|1688|Count of Matches in Tournament|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1688.Count-of-Matches-in-Tournament)|82.6%|Easy||
|1688|Count of Matches in Tournament|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1688.Count-of-Matches-in-Tournament)|82.5%|Easy||
|1689|Partitioning Into Minimum Number Of Deci-Binary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1689.Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers)|87.4%|Medium||
|1690|Stone Game VII|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1690.Stone-Game-VII)|47.6%|Medium||
|1691|Maximum Height by Stacking Cuboids ||49.9%|Hard||
|1692|Count Ways to Distribute Candies||62.0%|Hard||
|1692|Count Ways to Distribute Candies||62.1%|Hard||
|1693|Daily Leads and Partners||90.9%|Easy||
|1694|Reformat Phone Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1694.Reformat-Phone-Number)|66.2%|Easy||
|1694|Reformat Phone Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1694.Reformat-Phone-Number)|66.3%|Easy||
|1695|Maximum Erasure Value|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1695.Maximum-Erasure-Value)|49.6%|Medium||
|1696|Jump Game VI|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1696.Jump-Game-VI)|54.0%|Medium||
|1697|Checking Existence of Edge Length Limited Paths||55.8%|Hard||
|1698|Number of Distinct Substrings in a String||57.5%|Medium||
|1699|Number of Calls Between Two Persons||86.6%|Medium||
|1700|Number of Students Unable to Eat Lunch||69.2%|Easy||
|1700|Number of Students Unable to Eat Lunch||69.0%|Easy||
|1701|Average Waiting Time||61.4%|Medium||
|1702|Maximum Binary String After Change||60.4%|Medium||
|1703|Minimum Adjacent Swaps for K Consecutive Ones||40.1%|Hard||
|1704|Determine if String Halves Are Alike||77.6%|Easy||
|1705|Maximum Number of Eaten Apples||42.1%|Medium||
|1704|Determine if String Halves Are Alike||77.7%|Easy||
|1705|Maximum Number of Eaten Apples||42.0%|Medium||
|1706|Where Will the Ball Fall||59.2%|Medium||
|1707|Maximum XOR With an Element From Array||47.2%|Hard||
|1708|Largest Subarray Length K||63.9%|Easy||
|1709|Biggest Window Between Visits||82.4%|Medium||
|1709|Biggest Window Between Visits||82.5%|Medium||
|1710|Maximum Units on a Truck||70.5%|Easy||
|1711|Count Good Meals||26.1%|Medium||
|1712|Ways to Split Array Into Three Subarrays||29.8%|Medium||
|1713|Minimum Operations to Make a Subsequence||45.7%|Hard||
|1714|Sum Of Special Evenly-Spaced Elements In Array||47.9%|Hard||
|1715|Count Apples and Oranges||79.2%|Medium||
|1713|Minimum Operations to Make a Subsequence||45.6%|Hard||
|1714|Sum Of Special Evenly-Spaced Elements In Array||47.8%|Hard||
|1715|Count Apples and Oranges||79.3%|Medium||
|1716|Calculate Money in Leetcode Bank||67.4%|Easy||
|1717|Maximum Score From Removing Substrings||39.7%|Medium||
|1718|Construct the Lexicographically Largest Valid Sequence||44.8%|Medium||
|1719|Number Of Ways To Reconstruct A Tree||39.1%|Hard||
|1719|Number Of Ways To Reconstruct A Tree||39.2%|Hard||
|1720|Decode XORed Array||85.8%|Easy||
|1721|Swapping Nodes in a Linked List||64.7%|Medium||
|1722|Minimize Hamming Distance After Swap Operations||55.0%|Medium||
|1723|Find Minimum Time to Finish All Jobs||44.3%|Hard||
|1724|Checking Existence of Edge Length Limited Paths II||58.6%|Hard||
|1725|Number Of Rectangles That Can Form The Largest Square||77.7%|Easy||
|1726|Tuple with Same Product||55.4%|Medium||
|1725|Number Of Rectangles That Can Form The Largest Square||77.8%|Easy||
|1726|Tuple with Same Product||55.3%|Medium||
|1727|Largest Submatrix With Rearrangements||58.4%|Medium||
|1728|Cat and Mouse II||41.0%|Hard||
|1728|Cat and Mouse II||40.9%|Hard||
|1729|Find Followers Count||72.3%|Easy||
|1730|Shortest Path to Get Food||58.7%|Medium||
|1731|The Number of Employees Which Report to Each Employee||49.4%|Easy||
|1730|Shortest Path to Get Food||58.5%|Medium||
|1731|The Number of Employees Which Report to Each Employee||49.6%|Easy||
|1732|Find the Highest Altitude||81.7%|Easy||
|1733|Minimum Number of People to Teach||36.7%|Medium||
|1734|Decode XORed Permutation||51.2%|Medium||
|1735|Count Ways to Make Array With Product||49.1%|Hard||
|1736|Latest Time by Replacing Hidden Digits||41.3%|Easy||
|1734|Decode XORed Permutation||51.0%|Medium||
|1735|Count Ways to Make Array With Product||49.0%|Hard||
|1736|Latest Time by Replacing Hidden Digits||41.2%|Easy||
|1737|Change Minimum Characters to Satisfy One of Three Conditions||29.1%|Medium||
|1738|Find Kth Largest XOR Coordinate Value||62.4%|Medium||
|1739|Building Boxes||49.4%|Hard||
|1740|Find Distance in a Binary Tree||70.9%|Medium||
|1738|Find Kth Largest XOR Coordinate Value||62.3%|Medium||
|1739|Building Boxes||49.5%|Hard||
|1740|Find Distance in a Binary Tree||71.0%|Medium||
|1741|Find Total Time Spent by Each Employee||91.0%|Easy||
|1742|Maximum Number of Balls in a Box||75.0%|Easy||
|1743|Restore the Array From Adjacent Pairs||62.5%|Medium||
|1742|Maximum Number of Balls in a Box||74.9%|Easy||
|1743|Restore the Array From Adjacent Pairs||62.6%|Medium||
|1744|Can You Eat Your Favorite Candy on Your Favorite Day?||30.4%|Medium||
|1745|Palindrome Partitioning IV||48.8%|Hard||
|1746|Maximum Subarray Sum After One Operation||62.6%|Medium||
|1747|Leetflex Banned Accounts||69.9%|Medium||
|1748|Sum of Unique Elements||77.5%|Easy||
|1749|Maximum Absolute Sum of Any Subarray||49.6%|Medium||
|1750|Minimum Length of String After Deleting Similar Ends||41.6%|Medium||
|1751|Maximum Number of Events That Can Be Attended II||47.3%|Hard||
|1752|Check if Array Is Sorted and Rotated||70.3%|Easy||
|1745|Palindrome Partitioning IV||48.9%|Hard||
|1746|Maximum Subarray Sum After One Operation||62.8%|Medium||
|1747|Leetflex Banned Accounts||70.0%|Medium||
|1748|Sum of Unique Elements||77.4%|Easy||
|1749|Maximum Absolute Sum of Any Subarray||49.7%|Medium||
|1750|Minimum Length of String After Deleting Similar Ends||41.5%|Medium||
|1751|Maximum Number of Events That Can Be Attended II||47.2%|Hard||
|1752|Check if Array Is Sorted and Rotated||69.5%|Easy||
|1753|Maximum Score From Removing Stones||60.4%|Medium||
|1754|Largest Merge Of Two Strings||38.7%|Medium||
|1755|Closest Subsequence Sum||35.4%|Hard||
|1756|Design Most Recently Used Queue||82.3%|Medium||
|1756|Design Most Recently Used Queue||79.9%|Medium||
|1757|Recyclable and Low Fat Products||100.0%|Easy||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|
------------------------------------------------------------------

View File

@ -0,0 +1,17 @@
package leetcode
func checkPossibility(nums []int) bool {
count := 0
for i := 0; i < len(nums)-1; i++ {
if nums[i] > nums[i+1] {
count++
if count > 1 {
return false
}
if i > 0 && nums[i+1] < nums[i-1] {
nums[i+1] = nums[i]
}
}
}
return true
}

View File

@ -0,0 +1,47 @@
package leetcode
import (
"fmt"
"testing"
)
type question665 struct {
para665
ans665
}
// para 是参数
// one 代表第一个参数
type para665 struct {
nums []int
}
// ans 是答案
// one 代表第一个答案
type ans665 struct {
one bool
}
func Test_Problem665(t *testing.T) {
qs := []question665{
{
para665{[]int{4, 2, 3}},
ans665{true},
},
{
para665{[]int{4, 2, 1}},
ans665{false},
},
}
fmt.Printf("------------------------Leetcode Problem 665------------------------\n")
for _, q := range qs {
_, p := q.ans665, q.para665
fmt.Printf("【input】:%v 【output】:%v\n", p, checkPossibility(p.nums))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,59 @@
# [665. Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array/)
## 题目
Given an array `nums` with `n` integers, your task is to check if it could become non-decreasing by modifying **at most one element**.
We define an array is non-decreasing if `nums[i] <= nums[i + 1]` holds for every `i` (**0-based**) such that (`0 <= i <= n - 2`).
**Example 1:**
```
Input: nums = [4,2,3]
Output: true
Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
```
**Example 2:**
```
Input: nums = [4,2,1]
Output: false
Explanation: You can't get a non-decreasing array by modify at most one element.
```
**Constraints:**
- `n == nums.length`
- `1 <= n <= 104`
- `-10^5 <= nums[i] <= 10^5`
## 题目大意
给你一个长度为 n 的整数数组请你判断在 最多 改变 1 个元素的情况下该数组能否变成一个非递减数列。我们是这样定义一个非递减数列的 对于数组中任意的 i (0 <= i <= n-2),总满足 nums[i] <= nums[i + 1]。
## 解题思路
- 简单题。循环扫描数组,找到 `nums[i] > nums[i+1]` 这种递减组合。一旦这种组合超过 2 组,直接返回 false。找到第一组递减组合需要手动调节一次。如果 `nums[i + 1] < nums[i - 1]`,就算交换 `nums[i+1]``nums[i]`,交换结束,`nums[i - 1]` 仍然可能大于 `nums[i + 1]`,不满足题意。正确的做法应该是让较小的那个数变大,即 `nums[i + 1] = nums[i]`。两个元素相等满足非递减的要求。
## 代码
```go
package leetcode
func checkPossibility(nums []int) bool {
count := 0
for i := 0; i < len(nums)-1; i++ {
if nums[i] > nums[i+1] {
count++
if count > 1 {
return false
}
if i > 0 && nums[i+1] < nums[i-1] {
nums[i+1] = nums[i]
}
}
}
return true
}
```

View File

@ -0,0 +1,32 @@
package leetcode
import (
"github.com/halfrost/LeetCode-Go/structures"
)
// TreeNode define
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func trimBST(root *TreeNode, low int, high int) *TreeNode {
if root == nil {
return root
}
if root.Val > high {
return trimBST(root.Left, low, high)
}
if root.Val < low {
return trimBST(root.Right, low, high)
}
root.Left = trimBST(root.Left, low, high)
root.Right = trimBST(root.Right, low, high)
return root
}

View File

@ -0,0 +1,68 @@
package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question669 struct {
para669
ans669
}
// para 是参数
// one 代表第一个参数
type para669 struct {
one []int
low int
high int
}
// ans 是答案
// one 代表第一个答案
type ans669 struct {
one []int
}
func Test_Problem669(t *testing.T) {
qs := []question669{
{
para669{[]int{1, 0, 2}, 1, 2},
ans669{[]int{1, structures.NULL, 2}},
},
{
para669{[]int{3, 0, 4, structures.NULL, 2, structures.NULL, structures.NULL, 1}, 1, 3},
ans669{[]int{3, 2, structures.NULL, 1}},
},
{
para669{[]int{1}, 1, 2},
ans669{[]int{1}},
},
{
para669{[]int{1, structures.NULL, 2}, 1, 3},
ans669{[]int{1, structures.NULL, 2}},
},
{
para669{[]int{1, structures.NULL, 2}, 2, 4},
ans669{[]int{2}},
},
}
fmt.Printf("------------------------Leetcode Problem 669------------------------\n")
for _, q := range qs {
_, p := q.ans669, q.para669
fmt.Printf("【input】:%v ", p)
root := structures.Ints2TreeNode(p.one)
fmt.Printf("【output】:%v \n", structures.Tree2ints(trimBST(root, p.low, p.high)))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,100 @@
# [669. Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree/)
## 题目
Given the `root` of a binary search tree and the lowest and highest boundaries as `low` and `high`, trim the tree so that all its elements lies in `[low, high]`. Trimming the tree should **not** change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a **unique answer**.
Return *the root of the trimmed binary search tree*. Note that the root may change depending on the given bounds.
**Example 1:**
![https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg](https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg)
```
Input: root = [1,0,2], low = 1, high = 2
Output: [1,null,2]
```
**Example 2:**
![https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg](https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg)
```
Input: root = [3,0,4,null,2,null,null,1], low = 1, high = 3
Output: [3,2,null,1]
```
**Example 3:**
```
Input: root = [1], low = 1, high = 2
Output: [1]
```
**Example 4:**
```
Input: root = [1,null,2], low = 1, high = 3
Output: [1,null,2]
```
**Example 5:**
```
Input: root = [1,null,2], low = 2, high = 4
Output: [2]
```
**Constraints:**
- The number of nodes in the tree in the range `[1, 10^4]`.
- `0 <= Node.val <= 10^4`
- The value of each node in the tree is **unique**.
- `root` is guaranteed to be a valid binary search tree.
- `0 <= low <= high <= 10^4`
## 题目大意
给你二叉搜索树的根节点 root 同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树使得所有节点的值在[low, high]中。修剪树不应该改变保留在树中的元素的相对结构(即,如果没有被移除,原有的父代子代关系都应当保留)。 可以证明,存在唯一的答案。所以结果应当返回修剪好的二叉搜索树的新的根节点。注意,根节点可能会根据给定的边界发生改变。
## 解题思路
- 这一题考察二叉搜索树中的递归遍历。递归遍历二叉搜索树每个结点,根据有序性,当前结点如果比 high 大,那么当前结点的右子树全部修剪掉,再递归修剪左子树;当前结点如果比 low 小,那么当前结点的左子树全部修剪掉,再递归修剪右子树。处理完越界的情况,剩下的情况都在区间内,分别递归修剪左子树和右子树即可。
## 代码
```go
package leetcode
import (
"github.com/halfrost/LeetCode-Go/structures"
)
// TreeNode define
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func trimBST(root *TreeNode, low int, high int) *TreeNode {
if root == nil {
return root
}
if root.Val > high {
return trimBST(root.Left, low, high)
}
if root.Val < low {
return trimBST(root.Right, low, high)
}
root.Left = trimBST(root.Left, low, high)
root.Right = trimBST(root.Right, low, high)
return root
}
```

View File

@ -0,0 +1,20 @@
package leetcode
func maxScore(cardPoints []int, k int) int {
windowSize, sum := len(cardPoints)-k, 0
for _, val := range cardPoints[:windowSize] {
sum += val
}
minSum := sum
for i := windowSize; i < len(cardPoints); i++ {
sum += cardPoints[i] - cardPoints[i-windowSize]
if sum < minSum {
minSum = sum
}
}
total := 0
for _, pt := range cardPoints {
total += pt
}
return total - minSum
}

View File

@ -0,0 +1,63 @@
package leetcode
import (
"fmt"
"testing"
)
type question1423 struct {
para1423
ans1423
}
// para 是参数
// one 代表第一个参数
type para1423 struct {
cardPoints []int
k int
}
// ans 是答案
// one 代表第一个答案
type ans1423 struct {
one int
}
func Test_Problem1423(t *testing.T) {
qs := []question1423{
{
para1423{[]int{1, 2, 3, 4, 5, 6, 1}, 3},
ans1423{12},
},
{
para1423{[]int{2, 2, 2}, 2},
ans1423{4},
},
{
para1423{[]int{9, 7, 7, 9, 7, 7, 9}, 7},
ans1423{55},
},
{
para1423{[]int{1, 1000, 1}, 1},
ans1423{1},
},
{
para1423{[]int{1, 79, 80, 1, 1, 1, 200, 1}, 3},
ans1423{202},
},
}
fmt.Printf("------------------------Leetcode Problem 1423------------------------\n")
for _, q := range qs {
_, p := q.ans1423, q.para1423
fmt.Printf("【input】:%v 【output】:%v\n", p, maxScore(p.cardPoints, p.k))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,90 @@
# [1423. Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/)
## 题目
There are several cards **arranged in a row**, and each card has an associated number of points The points are given in the integer array `cardPoints`.
In one step, you can take one card from the beginning or from the end of the row. You have to take exactly `k` cards.
Your score is the sum of the points of the cards you have taken.
Given the integer array `cardPoints` and the integer `k`, return the *maximum score* you can obtain.
**Example 1:**
```
Input: cardPoints = [1,2,3,4,5,6,1], k = 3
Output: 12
Explanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.
```
**Example 2:**
```
Input: cardPoints = [2,2,2], k = 2
Output: 4
Explanation: Regardless of which two cards you take, your score will always be 4.
```
**Example 3:**
```
Input: cardPoints = [9,7,7,9,7,7,9], k = 7
Output: 55
Explanation: You have to take all the cards. Your score is the sum of points of all cards.
```
**Example 4:**
```
Input: cardPoints = [1,1000,1], k = 1
Output: 1
Explanation: You cannot take the card in the middle. Your best score is 1.
```
**Example 5:**
```
Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
Output: 202
```
**Constraints:**
- `1 <= cardPoints.length <= 10^5`
- `1 <= cardPoints[i] <= 10^4`
- `1 <= k <= cardPoints.length`
## 题目大意
几张卡牌 排成一行,每张卡牌都有一个对应的点数。点数由整数数组 cardPoints 给出。每次行动,你可以从行的开头或者末尾拿一张卡牌,最终你必须正好拿 k 张卡牌。你的点数就是你拿到手中的所有卡牌的点数之和。给你一个整数数组 cardPoints 和整数 k请你返回可以获得的最大点数。
## 解题思路
- 这一题是滑动窗口题的简化题。从卡牌两边取 K 张牌,可以转换成在中间连续取 n-K 张牌。从两边取牌的点数最大,意味着剩下来中间牌的点数最小。扫描一遍数组,在每一个窗口大小为 n-K 的窗口内计算累加和,记录下最小的累加和。题目最终求的最大点数等于牌的总和减去中间最小的累加和。
## 代码
```go
package leetcode
func maxScore(cardPoints []int, k int) int {
windowSize, sum := len(cardPoints)-k, 0
for _, val := range cardPoints[:windowSize] {
sum += val
}
minSum := sum
for i := windowSize; i < len(cardPoints); i++ {
sum += cardPoints[i] - cardPoints[i-windowSize]
if sum < minSum {
minSum = sum
}
}
total := 0
for _, pt := range cardPoints {
total += pt
}
return total - minSum
}
```

View File

@ -1,45 +1,52 @@
package leetcode
func cherryPickup(grid [][]int) int {
m, n := len(grid), len(grid[0])
old, new := make([]int, n*n), make([]int, n*n)
for i := range old {
old[i] = -0xffffff
rows, cols := len(grid), len(grid[0])
dp := make([][][]int, rows)
for i := 0; i < rows; i++ {
dp[i] = make([][]int, cols)
for j := 0; j < cols; j++ {
dp[i][j] = make([]int, cols)
}
}
old[n-1] = grid[0][0]+grid[0][n-1]
// dp
for k:=1; k<m; k++ {
for s:=0; s<n*n; s++ {
new[s] = -0xffffff
c1, c2 := s/n, s%n
toadd := grid[k][c1]
if c1 != c2 {
toadd += grid[k][c2]
}
for _, d1 := range []int{1,0,-1} {
for _, d2 := range []int{1,0,-1} {
nc1, nc2 := c1+d1, c2+d2
if nc1>=0 && nc1<n && nc2>=0 && nc2<n && old[nc1*n+nc2]>=0 {
new[s] = max(new[s], old[nc1*n+nc2]+toadd)
for i := 0; i < rows; i++ {
for j := 0; j <= i && j < cols; j++ {
for k := cols - 1; k >= cols-1-i && k >= 0; k-- {
max := 0
for a := j - 1; a <= j+1; a++ {
for b := k - 1; b <= k+1; b++ {
sum := isInBoard(dp, i-1, a, b)
if a == b && i > 0 && a >= 0 && a < cols {
sum -= grid[i-1][a]
}
if sum > max {
max = sum
}
}
}
if j == k {
max += grid[i][j]
} else {
max += grid[i][j] + grid[i][k]
}
dp[i][j][k] = max
}
}
old, new = new, old
}
allmax := 0
for _, v := range old {
if v>allmax {
allmax = v
count := 0
for j := 0; j < cols && j < rows; j++ {
for k := cols - 1; k >= 0 && k >= cols-rows; k-- {
if dp[rows-1][j][k] > count {
count = dp[rows-1][j][k]
}
}
}
return allmax
return count
}
func max(a, b int) int {
if a>b {
return a
func isInBoard(dp [][][]int, i, j, k int) int {
if i < 0 || j < 0 || j >= len(dp[0]) || k < 0 || k >= len(dp[0]) {
return 0
}
return b
return dp[i][j][k]
}

View File

@ -5,65 +5,65 @@ import (
"testing"
)
type question1436 struct {
para1436
ans1436
type question1463 struct {
para1463
ans1463
}
type para1436 struct {
type para1463 struct {
grid [][]int
}
type ans1436 struct {
type ans1463 struct {
ans int
}
func Test_Problem1436(t *testing.T) {
func Test_Problem1463(t *testing.T) {
qs := []question1436{
qs := []question1463{
{
para1436{[][]int{
para1463{[][]int{
{3, 1, 1},
{2, 5, 1},
{1, 5, 5},
{2, 1, 1},
}},
ans1436{24},
ans1463{24},
},
{
para1436{[][]int{
para1463{[][]int{
{1, 0, 0, 0, 0, 0, 1},
{2, 0, 0, 0, 0, 3, 0},
{2, 0, 9, 0, 0, 0, 0},
{0, 3, 0, 5, 4, 0, 0},
{1, 0, 2, 3, 0, 0, 6},
}},
ans1436{28},
ans1463{28},
},
{
para1436{[][]int{
para1463{[][]int{
{1, 0, 0, 3},
{0, 0, 0, 3},
{0, 0, 3, 3},
{9, 0, 3, 3},
}},
ans1436{22},
ans1463{22},
},
{
para1436{[][]int{
para1463{[][]int{
{1, 1},
{1, 1},
}},
ans1436{4},
ans1463{4},
},
}
fmt.Printf("------------------------Leetcode Problem 1436------------------------\n")
fmt.Printf("------------------------Leetcode Problem 1463------------------------\n")
for _, q := range qs {
_, p := q.ans1436, q.para1436
_, p := q.ans1463, q.para1463
fmt.Printf("【input】:%v ", p)
fmt.Printf("【output】:%v \n", cherryPickup(p.grid))
}

View File

@ -1,44 +1,148 @@
# [1463. Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii/)
Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.
You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.
## 题目
Return the maximum number of cherries collection using both robots by following the rules below:
Given a `rows x cols` matrix `grid` representing a field of cherries. Each cell in `grid` represents the number of cherries that you can collect.
From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
When both robots stay on the same cell, only one of them takes the cherries.
Both robots cannot move outside of the grid at any moment.
Both robots should reach the bottom row in the grid.
You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.
Return the maximum number of cherries collection using both robots  by following the rules below:
- From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
- When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
- When both robots stay on the same cell, only one of them takes the cherries.
- Both robots cannot move outside of the grid at any moment.
- Both robots should reach the bottom row in the `grid`.
**Example 1:**
![https://assets.leetcode.com/uploads/2020/04/29/sample_1_1802.png](https://assets.leetcode.com/uploads/2020/04/29/sample_1_1802.png)
## Example 1:
```
Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
Output: 24
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
Total of cherries: 12 + 12 = 24.
```
## Example 2:
**Example 2:**
![https://assets.leetcode.com/uploads/2020/04/23/sample_2_1802.png](https://assets.leetcode.com/uploads/2020/04/23/sample_2_1802.png)
```
Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
Output: 28
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
Total of cherries: 17 + 11 = 28.
```
## Example 3:
**Example 3:**
```
Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
Output: 22
```
## Example 4:
**Example 4:**
```
Input: grid = [[1,1],[1,1]]
Output: 4
```
**Constraints:**
- `rows == grid.length`
- `cols == grid[i].length`
- `2 <= rows, cols <= 70`
- `0 <= grid[i][j] <= 100`
## 题目大意
给你一个 rows x cols 的矩阵 grid 来表示一块樱桃地。 grid 中每个格子的数字表示你能获得的樱桃数目。你有两个机器人帮你收集樱桃机器人 1 从左上角格子 (0,0) 出发,机器人 2 从右上角格子 (0, cols-1) 出发。请你按照如下规则,返回两个机器人能收集的最多樱桃数目:
- 从格子 (i,j) 出发,机器人可以移动到格子 (i+1, j-1)(i+1, j) 或者 (i+1, j+1) 。
- 当一个机器人经过某个格子时,它会把该格子内所有的樱桃都摘走,然后这个位置会变成空格子,即没有樱桃的格子。
- 当两个机器人同时到达同一个格子时,它们中只有一个可以摘到樱桃。
- 两个机器人在任意时刻都不能移动到 grid 外面。
- 两个机器人最后都要到达 grid 最底下一行。
## 解题思路
- 如果没有思路可以先用暴力解法 DFS 尝试。读完题可以分析出求最多樱桃数目里面包含了很多重叠子问题于是乎自然而然思路是用动态规划。数据规模上看100 的数据规模最多能保证 O(n^3) 时间复杂度的算法不超时。
- 这一题的变量有 2 个,一个是行号,另外一个是机器人所在的列。具体来说,机器人每走一步的移动范围只能往下走,不能往上走,所以 2 个机器人所在行号一定相同。两个机器人的列号不同。综上,变量有 3 个1 个行号和2 个列号。定义 `dp[i][j][k]` 代表第一个机器人从 (0,0) 走到 (i,k) 坐标,第二个机器人从 (0,n-1) 走到 (i,k) 坐标,两者最多能收集樱桃的数目。状态转移方程为
{{< katex display >}}
dp[i][j][k] = max \begin{pmatrix}\begin{array}{lr} dp[i-1][f(j_1))][f(j_2)] + grid[i][j_1] + grid[i][j_2], j_1\neq j_2  \\ dp[i-1][f(j_1))][f(j_2)] + grid[i][j_1], j_1 = j_2 \end{array} \end{pmatrix}
{{< /katex>}}
其中:
{{< katex display >}}
\left\{\begin{matrix}f(j_1) \in [0,n), f(j_1) - j_1 \in [-1,0,1]\\ f(j_2) \in [0,n), f(j_2) - j_2 \in [-1,0,1]\end{matrix}\right.
{{< /katex>}}
即状态转移过程中需要在 `[j1 - 1, j1, j1 + 1]` 中枚举 `j1`,同理,在 在 `[j2 - 1, j2, j2 + 1]` 中枚举 `j2`,每个状态转移需要枚举这 3*3 = 9 种状态。
- 边界条件 `dp[i][0][n-1] = grid[0][0] + grid[0][n-1]`,最终答案存储在 `dp[m-1]` 行中,循环找出 `dp[m-1][j1][j2]` 中的最大值,到此该题得解。
## 代码
```go
package leetcode
func cherryPickup(grid [][]int) int {
rows, cols := len(grid), len(grid[0])
dp := make([][][]int, rows)
for i := 0; i < rows; i++ {
dp[i] = make([][]int, cols)
for j := 0; j < cols; j++ {
dp[i][j] = make([]int, cols)
}
}
for i := 0; i < rows; i++ {
for j := 0; j <= i && j < cols; j++ {
for k := cols - 1; k >= cols-1-i && k >= 0; k-- {
max := 0
for a := j - 1; a <= j+1; a++ {
for b := k - 1; b <= k+1; b++ {
sum := isInBoard(dp, i-1, a, b)
if a == b && i > 0 && a >= 0 && a < cols {
sum -= grid[i-1][a]
}
if sum > max {
max = sum
}
}
}
if j == k {
max += grid[i][j]
} else {
max += grid[i][j] + grid[i][k]
}
dp[i][j][k] = max
}
}
}
count := 0
for j := 0; j < cols && j < rows; j++ {
for k := cols - 1; k >= 0 && k >= cols-rows; k-- {
if dp[rows-1][j][k] > count {
count = dp[rows-1][j][k]
}
}
}
return count
}
func isInBoard(dp [][][]int, i, j, k int) int {
if i < 0 || j < 0 || j >= len(dp[0]) || k < 0 || k >= len(dp[0]) {
return 0
}
return dp[i][j][k]
}
```

View File

@ -0,0 +1,30 @@
package leetcode
import (
"github.com/halfrost/LeetCode-Go/template"
)
func maxNumEdgesToRemove(n int, edges [][]int) int {
alice, bob, res := template.UnionFind{}, template.UnionFind{}, len(edges)
alice.Init(n)
bob.Init(n)
for _, e := range edges {
x, y := e[1]-1, e[2]-1
if e[0] == 3 && (!(alice.Find(x) == alice.Find(y)) || !(bob.Find(x) == bob.Find(y))) {
alice.Union(x, y)
bob.Union(x, y)
res--
}
}
ufs := [2]*template.UnionFind{&alice, &bob}
for _, e := range edges {
if tp := e[0]; tp < 3 && !(ufs[tp-1].Find(e[1]-1) == ufs[tp-1].Find(e[2]-1)) {
ufs[tp-1].Union(e[1]-1, e[2]-1)
res--
}
}
if alice.TotalCount() > 1 || bob.TotalCount() > 1 {
return -1
}
return res
}

View File

@ -0,0 +1,53 @@
package leetcode
import (
"fmt"
"testing"
)
type question1579 struct {
para1579
ans1579
}
// para 是参数
// one 代表第一个参数
type para1579 struct {
n int
edges [][]int
}
// ans 是答案
// one 代表第一个答案
type ans1579 struct {
one int
}
func Test_Problem1579(t *testing.T) {
qs := []question1579{
{
para1579{4, [][]int{{3, 1, 2}, {3, 2, 3}, {1, 1, 3}, {1, 2, 4}, {1, 1, 2}, {2, 3, 4}}},
ans1579{2},
},
{
para1579{4, [][]int{{3, 1, 2}, {3, 2, 3}, {1, 1, 4}, {2, 1, 4}}},
ans1579{0},
},
{
para1579{4, [][]int{{3, 2, 3}, {1, 1, 2}, {2, 3, 4}}},
ans1579{-1},
},
}
fmt.Printf("------------------------Leetcode Problem 1579------------------------\n")
for _, q := range qs {
_, p := q.ans1579, q.para1579
fmt.Printf("【input】:%v 【output】:%v \n", p, maxNumEdgesToRemove(p.n, p.edges))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,103 @@
# [1579. Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/)
## 题目
Alice and Bob have an undirected graph of `n` nodes and 3 types of edges:
- Type 1: Can be traversed by Alice only.
- Type 2: Can be traversed by Bob only.
- Type 3: Can by traversed by both Alice and Bob.
Given an array `edges` where `edges[i] = [typei, ui, vi]` represents a bidirectional edge of type `typei` between nodes `ui` and `vi`, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.
Return *the maximum number of edges you can remove, or return* `-1` *if it's impossible for the graph to be fully traversed by Alice and Bob.*
**Example 1:**
![https://assets.leetcode.com/uploads/2020/08/19/ex1.png](https://assets.leetcode.com/uploads/2020/08/19/ex1.png)
```
Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]
Output: 2
Explanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.
```
**Example 2:**
![https://assets.leetcode.com/uploads/2020/08/19/ex2.png](https://assets.leetcode.com/uploads/2020/08/19/ex2.png)
```
Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]
Output: 0
Explanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.
```
**Example 3:**
![https://assets.leetcode.com/uploads/2020/08/19/ex3.png](https://assets.leetcode.com/uploads/2020/08/19/ex3.png)
```
Input: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]
Output: -1
Explanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.
```
**Constraints:**
- `1 <= n <= 10^5`
- `1 <= edges.length <= min(10^5, 3 * n * (n-1) / 2)`
- `edges[i].length == 3`
- `1 <= edges[i][0] <= 3`
- `1 <= edges[i][1] < edges[i][2] <= n`
- All tuples `(typei, ui, vi)` are distinct.
## 题目大意
Alice 和 Bob 共有一个无向图,其中包含 n 个节点和 3  种类型的边:
- 类型 1只能由 Alice 遍历。
- 类型 2只能由 Bob 遍历。
- 类型 3Alice 和 Bob 都可以遍历。
给你一个数组 edges ,其中 edges[i] = [typei, ui, vi] 表示节点 ui 和 vi 之间存在类型为 typei 的双向边。请你在保证图仍能够被 Alice和 Bob 完全遍历的前提下找出可以删除的最大边数。如果从任何节点开始Alice 和 Bob 都可以到达所有其他节点,则认为图是可以完全遍历的。返回可以删除的最大边数,如果 Alice 和 Bob 无法完全遍历图,则返回 -1 。
## 解题思路
- 本题是第 1319 题的加强版。在第 1319 题中只有一个人,同样也是判断在保证图可连通的基础上,删掉最多边的条数。这一题只不过变成了 2 个人。解题思路依旧是并查集。
- 初始化 2 个并查集,分别表示 Alice 和 Bob。先合并公共边每合并一条边可删除的最大总边数便减少 1 。再合并 2 人各自的单独的边,同样是每合并一条边,每合并一条边,可删除的最大总边数便减少 1 。合并完所有的边2 人的并查集内部集合数仍大于 1那么则代表 2 人无法完全遍历图,则输出 -1。如果 2 人的并查集内部集合都是 1代表整个图都连通了。输出可以删除的最大边数。
## 代码
```go
package leetcode
import (
"github.com/halfrost/LeetCode-Go/template"
)
func maxNumEdgesToRemove(n int, edges [][]int) int {
alice, bob, res := template.UnionFind{}, template.UnionFind{}, len(edges)
alice.Init(n)
bob.Init(n)
for _, e := range edges {
x, y := e[1]-1, e[2]-1
if e[0] == 3 && (!(alice.Find(x) == alice.Find(y)) || !(bob.Find(x) == bob.Find(y))) {
alice.Union(x, y)
bob.Union(x, y)
res--
}
}
ufs := [2]*template.UnionFind{&alice, &bob}
for _, e := range edges {
if tp := e[0]; tp < 3 && !(ufs[tp-1].Find(e[1]-1) == ufs[tp-1].Find(e[2]-1)) {
ufs[tp-1].Union(e[1]-1, e[2]-1)
res--
}
}
if alice.TotalCount() > 1 || bob.TotalCount() > 1 {
return -1
}
return res
}
```

View File

@ -155,5 +155,5 @@ func widthOfBinaryTree(root *TreeNode) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0661.Image-Smoother/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0668.Kth-Smallest-Number-in-Multiplication-Table/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0665.Non-decreasing-Array/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,66 @@
# [665. Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array/)
## 题目
Given an array `nums` with `n` integers, your task is to check if it could become non-decreasing by modifying **at most one element**.
We define an array is non-decreasing if `nums[i] <= nums[i + 1]` holds for every `i` (**0-based**) such that (`0 <= i <= n - 2`).
**Example 1:**
```
Input: nums = [4,2,3]
Output: true
Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
```
**Example 2:**
```
Input: nums = [4,2,1]
Output: false
Explanation: You can't get a non-decreasing array by modify at most one element.
```
**Constraints:**
- `n == nums.length`
- `1 <= n <= 104`
- `-10^5 <= nums[i] <= 10^5`
## 题目大意
给你一个长度为 n 的整数数组请你判断在 最多 改变 1 个元素的情况下该数组能否变成一个非递减数列。我们是这样定义一个非递减数列的 对于数组中任意的 i (0 <= i <= n-2),总满足 nums[i] <= nums[i + 1]。
## 解题思路
- 简单题。循环扫描数组,找到 `nums[i] > nums[i+1]` 这种递减组合。一旦这种组合超过 2 组,直接返回 false。找到第一组递减组合需要手动调节一次。如果 `nums[i + 1] < nums[i - 1]`,就算交换 `nums[i+1]``nums[i]`,交换结束,`nums[i - 1]` 仍然可能大于 `nums[i + 1]`,不满足题意。正确的做法应该是让较小的那个数变大,即 `nums[i + 1] = nums[i]`。两个元素相等满足非递减的要求。
## 代码
```go
package leetcode
func checkPossibility(nums []int) bool {
count := 0
for i := 0; i < len(nums)-1; i++ {
if nums[i] > nums[i+1] {
count++
if count > 1 {
return false
}
if i > 0 && nums[i+1] < nums[i-1] {
nums[i+1] = nums[i]
}
}
}
return true
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0662.Maximum-Width-of-Binary-Tree/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0668.Kth-Smallest-Number-in-Multiplication-Table/">下一页➡️</a></p>
</div>

View File

@ -86,6 +86,6 @@ func counterKthNum(m, n, mid int) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0662.Maximum-Width-of-Binary-Tree/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0674.Longest-Continuous-Increasing-Subsequence/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0665.Non-decreasing-Array/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0669.Trim-a-Binary-Search-Tree/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,107 @@
# [669. Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree/)
## 题目
Given the `root` of a binary search tree and the lowest and highest boundaries as `low` and `high`, trim the tree so that all its elements lies in `[low, high]`. Trimming the tree should **not** change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a **unique answer**.
Return *the root of the trimmed binary search tree*. Note that the root may change depending on the given bounds.
**Example 1:**
![https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg](https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg)
```
Input: root = [1,0,2], low = 1, high = 2
Output: [1,null,2]
```
**Example 2:**
![https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg](https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg)
```
Input: root = [3,0,4,null,2,null,null,1], low = 1, high = 3
Output: [3,2,null,1]
```
**Example 3:**
```
Input: root = [1], low = 1, high = 2
Output: [1]
```
**Example 4:**
```
Input: root = [1,null,2], low = 1, high = 3
Output: [1,null,2]
```
**Example 5:**
```
Input: root = [1,null,2], low = 2, high = 4
Output: [2]
```
**Constraints:**
- The number of nodes in the tree in the range `[1, 10^4]`.
- `0 <= Node.val <= 10^4`
- The value of each node in the tree is **unique**.
- `root` is guaranteed to be a valid binary search tree.
- `0 <= low <= high <= 10^4`
## 题目大意
给你二叉搜索树的根节点 root 同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树使得所有节点的值在[low, high]中。修剪树不应该改变保留在树中的元素的相对结构(即,如果没有被移除,原有的父代子代关系都应当保留)。 可以证明,存在唯一的答案。所以结果应当返回修剪好的二叉搜索树的新的根节点。注意,根节点可能会根据给定的边界发生改变。
## 解题思路
- 这一题考察二叉搜索树中的递归遍历。递归遍历二叉搜索树每个结点,根据有序性,当前结点如果比 high 大,那么当前结点的右子树全部修剪掉,再递归修剪左子树;当前结点如果比 low 小,那么当前结点的左子树全部修剪掉,再递归修剪右子树。处理完越界的情况,剩下的情况都在区间内,分别递归修剪左子树和右子树即可。
## 代码
```go
package leetcode
import (
"github.com/halfrost/LeetCode-Go/structures"
)
// TreeNode define
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func trimBST(root *TreeNode, low int, high int) *TreeNode {
if root == nil {
return root
}
if root.Val > high {
return trimBST(root.Left, low, high)
}
if root.Val < low {
return trimBST(root.Right, low, high)
}
root.Left = trimBST(root.Left, low, high)
root.Right = trimBST(root.Right, low, high)
return root
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0668.Kth-Smallest-Number-in-Multiplication-Table/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0674.Longest-Continuous-Increasing-Subsequence/">下一页➡️</a></p>
</div>

View File

@ -71,6 +71,6 @@ func max(a, b int) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0668.Kth-Smallest-Number-in-Multiplication-Table/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0669.Trim-a-Binary-Search-Tree/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0600~0699/0676.Implement-Magic-Dictionary/">下一页➡️</a></p>
</div>

View File

@ -93,5 +93,5 @@ func createTargetArray(nums []int, index []int) []int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1300~1399/1385.Find-the-Distance-Value-Between-Two-Arrays/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1400~1499/1437.Check-If-All-1s-Are-at-Least-Length-K-Places-Away/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,97 @@
# [1423. Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/)
## 题目
There are several cards **arranged in a row**, and each card has an associated number of points The points are given in the integer array `cardPoints`.
In one step, you can take one card from the beginning or from the end of the row. You have to take exactly `k` cards.
Your score is the sum of the points of the cards you have taken.
Given the integer array `cardPoints` and the integer `k`, return the *maximum score* you can obtain.
**Example 1:**
```
Input: cardPoints = [1,2,3,4,5,6,1], k = 3
Output: 12
Explanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.
```
**Example 2:**
```
Input: cardPoints = [2,2,2], k = 2
Output: 4
Explanation: Regardless of which two cards you take, your score will always be 4.
```
**Example 3:**
```
Input: cardPoints = [9,7,7,9,7,7,9], k = 7
Output: 55
Explanation: You have to take all the cards. Your score is the sum of points of all cards.
```
**Example 4:**
```
Input: cardPoints = [1,1000,1], k = 1
Output: 1
Explanation: You cannot take the card in the middle. Your best score is 1.
```
**Example 5:**
```
Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
Output: 202
```
**Constraints:**
- `1 <= cardPoints.length <= 10^5`
- `1 <= cardPoints[i] <= 10^4`
- `1 <= k <= cardPoints.length`
## 题目大意
几张卡牌 排成一行,每张卡牌都有一个对应的点数。点数由整数数组 cardPoints 给出。每次行动,你可以从行的开头或者末尾拿一张卡牌,最终你必须正好拿 k 张卡牌。你的点数就是你拿到手中的所有卡牌的点数之和。给你一个整数数组 cardPoints 和整数 k请你返回可以获得的最大点数。
## 解题思路
- 这一题是滑动窗口题的简化题。从卡牌两边取 K 张牌,可以转换成在中间连续取 n-K 张牌。从两边取牌的点数最大,意味着剩下来中间牌的点数最小。扫描一遍数组,在每一个窗口大小为 n-K 的窗口内计算累加和,记录下最小的累加和。题目最终求的最大点数等于牌的总和减去中间最小的累加和。
## 代码
```go
package leetcode
func maxScore(cardPoints []int, k int) int {
windowSize, sum := len(cardPoints)-k, 0
for _, val := range cardPoints[:windowSize] {
sum += val
}
minSum := sum
for i := windowSize; i < len(cardPoints); i++ {
sum += cardPoints[i] - cardPoints[i-windowSize]
if sum < minSum {
minSum = sum
}
}
total := 0
for _, pt := range cardPoints {
total += pt
}
return total - minSum
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1300~1399/1389.Create-Target-Array-in-the-Given-Order/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1400~1499/1437.Check-If-All-1s-Are-at-Least-Length-K-Places-Away/">下一页➡️</a></p>
</div>

View File

@ -75,6 +75,6 @@ func kLengthApart(nums []int, k int) bool {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1300~1399/1389.Create-Target-Array-in-the-Given-Order/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1400~1499/1439.Find-the-Kth-Smallest-Sum-of-a-Matrix-With-Sorted-Rows/">下一页➡️</a></p>
</div>

View File

@ -1,48 +1,153 @@
# [1463. Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii/)
Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.
You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.
## 题目
Return the maximum number of cherries collection using both robots by following the rules below:
Given a `rows x cols` matrix `grid` representing a field of cherries. Each cell in `grid` represents the number of cherries that you can collect.
From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
When both robots stay on the same cell, only one of them takes the cherries.
Both robots cannot move outside of the grid at any moment.
Both robots should reach the bottom row in the grid.
You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.
Return the maximum number of cherries collection using both robots  by following the rules below:
- From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
- When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
- When both robots stay on the same cell, only one of them takes the cherries.
- Both robots cannot move outside of the grid at any moment.
- Both robots should reach the bottom row in the `grid`.
**Example 1:**
![https://assets.leetcode.com/uploads/2020/04/29/sample_1_1802.png](https://assets.leetcode.com/uploads/2020/04/29/sample_1_1802.png)
## Example 1:
```
Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
Output: 24
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
Total of cherries: 12 + 12 = 24.
```
## Example 2:
**Example 2:**
![https://assets.leetcode.com/uploads/2020/04/23/sample_2_1802.png](https://assets.leetcode.com/uploads/2020/04/23/sample_2_1802.png)
```
Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
Output: 28
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
Total of cherries: 17 + 11 = 28.
```
## Example 3:
**Example 3:**
```
Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
Output: 22
```
## Example 4:
**Example 4:**
```
Input: grid = [[1,1],[1,1]]
Output: 4
```
**Constraints:**
- `rows == grid.length`
- `cols == grid[i].length`
- `2 <= rows, cols <= 70`
- `0 <= grid[i][j] <= 100`
## 题目大意
给你一个 rows x cols 的矩阵 grid 来表示一块樱桃地。 grid 中每个格子的数字表示你能获得的樱桃数目。你有两个机器人帮你收集樱桃机器人 1 从左上角格子 (0,0) 出发,机器人 2 从右上角格子 (0, cols-1) 出发。请你按照如下规则,返回两个机器人能收集的最多樱桃数目:
- 从格子 (i,j) 出发,机器人可以移动到格子 (i+1, j-1)(i+1, j) 或者 (i+1, j+1) 。
- 当一个机器人经过某个格子时,它会把该格子内所有的樱桃都摘走,然后这个位置会变成空格子,即没有樱桃的格子。
- 当两个机器人同时到达同一个格子时,它们中只有一个可以摘到樱桃。
- 两个机器人在任意时刻都不能移动到 grid 外面。
- 两个机器人最后都要到达 grid 最底下一行。
## 解题思路
- 如果没有思路可以先用暴力解法 DFS 尝试。读完题可以分析出求最多樱桃数目里面包含了很多重叠子问题于是乎自然而然思路是用动态规划。数据规模上看100 的数据规模最多能保证 O(n^3) 时间复杂度的算法不超时。
- 这一题的变量有 2 个,一个是行号,另外一个是机器人所在的列。具体来说,机器人每走一步的移动范围只能往下走,不能往上走,所以 2 个机器人所在行号一定相同。两个机器人的列号不同。综上,变量有 3 个1 个行号和2 个列号。定义 `dp[i][j][k]` 代表第一个机器人从 (0,0) 走到 (i,k) 坐标,第二个机器人从 (0,n-1) 走到 (i,k) 坐标,两者最多能收集樱桃的数目。状态转移方程为
{{< katex display >}}
dp[i][j][k] = max \begin{pmatrix}\begin{array}{lr} dp[i-1][f(j_1))][f(j_2)] + grid[i][j_1] + grid[i][j_2], j_1\neq j_2  \\ dp[i-1][f(j_1))][f(j_2)] + grid[i][j_1], j_1 = j_2 \end{array} \end{pmatrix}
{{< /katex>}}
其中:
{{< katex display >}}
\left\{\begin{matrix}f(j_1) \in [0,n), f(j_1) - j_1 \in [-1,0,1]\\ f(j_2) \in [0,n), f(j_2) - j_2 \in [-1,0,1]\end{matrix}\right.
{{< /katex>}}
即状态转移过程中需要在 `[j1 - 1, j1, j1 + 1]` 中枚举 `j1`,同理,在 在 `[j2 - 1, j2, j2 + 1]` 中枚举 `j2`,每个状态转移需要枚举这 3*3 = 9 种状态。
- 边界条件 `dp[i][0][n-1] = grid[0][0] + grid[0][n-1]`,最终答案存储在 `dp[m-1]` 行中,循环找出 `dp[m-1][j1][j2]` 中的最大值,到此该题得解。
## 代码
```go
package leetcode
func cherryPickup(grid [][]int) int {
rows, cols := len(grid), len(grid[0])
dp := make([][][]int, rows)
for i := 0; i < rows; i++ {
dp[i] = make([][]int, cols)
for j := 0; j < cols; j++ {
dp[i][j] = make([]int, cols)
}
}
for i := 0; i < rows; i++ {
for j := 0; j <= i && j < cols; j++ {
for k := cols - 1; k >= cols-1-i && k >= 0; k-- {
max := 0
for a := j - 1; a <= j+1; a++ {
for b := k - 1; b <= k+1; b++ {
sum := isInBoard(dp, i-1, a, b)
if a == b && i > 0 && a >= 0 && a < cols {
sum -= grid[i-1][a]
}
if sum > max {
max = sum
}
}
}
if j == k {
max += grid[i][j]
} else {
max += grid[i][j] + grid[i][k]
}
dp[i][j][k] = max
}
}
}
count := 0
for j := 0; j < cols && j < rows; j++ {
for k := cols - 1; k >= 0 && k >= cols-rows; k-- {
if dp[rows-1][j][k] > count {
count = dp[rows-1][j][k]
}
}
}
return count
}
func isInBoard(dp [][][]int, i, j, k int) int {
if i < 0 || j < 0 || j >= len(dp[0]) || k < 0 || k >= len(dp[0]) {
return 0
}
return dp[i][j][k]
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">

View File

@ -111,5 +111,5 @@ func numWays(s string) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1539.Kth-Missing-Positive-Number/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,110 @@
# [1579. Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/)
## 题目
Alice and Bob have an undirected graph of `n` nodes and 3 types of edges:
- Type 1: Can be traversed by Alice only.
- Type 2: Can be traversed by Bob only.
- Type 3: Can by traversed by both Alice and Bob.
Given an array `edges` where `edges[i] = [typei, ui, vi]` represents a bidirectional edge of type `typei` between nodes `ui` and `vi`, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.
Return *the maximum number of edges you can remove, or return* `-1` *if it's impossible for the graph to be fully traversed by Alice and Bob.*
**Example 1:**
![https://assets.leetcode.com/uploads/2020/08/19/ex1.png](https://assets.leetcode.com/uploads/2020/08/19/ex1.png)
```
Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]
Output: 2
Explanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.
```
**Example 2:**
![https://assets.leetcode.com/uploads/2020/08/19/ex2.png](https://assets.leetcode.com/uploads/2020/08/19/ex2.png)
```
Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]
Output: 0
Explanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.
```
**Example 3:**
![https://assets.leetcode.com/uploads/2020/08/19/ex3.png](https://assets.leetcode.com/uploads/2020/08/19/ex3.png)
```
Input: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]
Output: -1
Explanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.
```
**Constraints:**
- `1 <= n <= 10^5`
- `1 <= edges.length <= min(10^5, 3 * n * (n-1) / 2)`
- `edges[i].length == 3`
- `1 <= edges[i][0] <= 3`
- `1 <= edges[i][1] < edges[i][2] <= n`
- All tuples `(typei, ui, vi)` are distinct.
## 题目大意
Alice 和 Bob 共有一个无向图,其中包含 n 个节点和 3  种类型的边:
- 类型 1只能由 Alice 遍历。
- 类型 2只能由 Bob 遍历。
- 类型 3Alice 和 Bob 都可以遍历。
给你一个数组 edges ,其中 edges[i] = [typei, ui, vi] 表示节点 ui 和 vi 之间存在类型为 typei 的双向边。请你在保证图仍能够被 Alice和 Bob 完全遍历的前提下找出可以删除的最大边数。如果从任何节点开始Alice 和 Bob 都可以到达所有其他节点,则认为图是可以完全遍历的。返回可以删除的最大边数,如果 Alice 和 Bob 无法完全遍历图,则返回 -1 。
## 解题思路
- 本题是第 1319 题的加强版。在第 1319 题中只有一个人,同样也是判断在保证图可连通的基础上,删掉最多边的条数。这一题只不过变成了 2 个人。解题思路依旧是并查集。
- 初始化 2 个并查集,分别表示 Alice 和 Bob。先合并公共边每合并一条边可删除的最大总边数便减少 1 。再合并 2 人各自的单独的边,同样是每合并一条边,每合并一条边,可删除的最大总边数便减少 1 。合并完所有的边2 人的并查集内部集合数仍大于 1那么则代表 2 人无法完全遍历图,则输出 -1。如果 2 人的并查集内部集合都是 1代表整个图都连通了。输出可以删除的最大边数。
## 代码
```go
package leetcode
import (
"github.com/halfrost/LeetCode-Go/template"
)
func maxNumEdgesToRemove(n int, edges [][]int) int {
alice, bob, res := template.UnionFind{}, template.UnionFind{}, len(edges)
alice.Init(n)
bob.Init(n)
for _, e := range edges {
x, y := e[1]-1, e[2]-1
if e[0] == 3 && (!(alice.Find(x) == alice.Find(y)) || !(bob.Find(x) == bob.Find(y))) {
alice.Union(x, y)
bob.Union(x, y)
res--
}
}
ufs := [2]*template.UnionFind{&alice, &bob}
for _, e := range edges {
if tp := e[0]; tp < 3 && !(ufs[tp-1].Find(e[1]-1) == ufs[tp-1].Find(e[2]-1)) {
ufs[tp-1].Union(e[1]-1, e[2]-1)
res--
}
}
if alice.TotalCount() > 1 || bob.TotalCount() > 1 {
return -1
}
return res
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1573.Number-of-Ways-to-Split-a-String/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation/">下一页➡️</a></p>
</div>

View File

@ -97,6 +97,6 @@ func canFormArray(arr []int, pieces [][]int) bool {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1573.Number-of-Ways-to-Split-a-String/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings/">下一页➡️</a></p>
</div>

View File

@ -24,7 +24,7 @@ weight: 1
|0040|Combination Sum II|[Go]({{< relref "/ChapterFour/0001~0099/0040.Combination-Sum-II.md" >}})|Medium| O(n log n)| O(n)||50.0%|
|0041|First Missing Positive|[Go]({{< relref "/ChapterFour/0001~0099/0041.First-Missing-Positive.md" >}})|Hard| O(n)| O(n)||33.6%|
|0042|Trapping Rain Water|[Go]({{< relref "/ChapterFour/0001~0099/0042.Trapping-Rain-Water.md" >}})|Hard| O(n)| O(1)|❤️|51.0%|
|0048|Rotate Image|[Go]({{< relref "/ChapterFour/0001~0099/0048.Rotate-Image.md" >}})|Medium| O(n)| O(1)||59.7%|
|0048|Rotate Image|[Go]({{< relref "/ChapterFour/0001~0099/0048.Rotate-Image.md" >}})|Medium| O(n)| O(1)||59.8%|
|0053|Maximum Subarray|[Go]({{< relref "/ChapterFour/0001~0099/0053.Maximum-Subarray.md" >}})|Easy| O(n)| O(n)||47.7%|
|0054|Spiral Matrix|[Go]({{< relref "/ChapterFour/0001~0099/0054.Spiral-Matrix.md" >}})|Medium| O(n)| O(n^2)||35.9%|
|0055|Jump Game|[Go]({{< relref "/ChapterFour/0001~0099/0055.Jump-Game.md" >}})|Medium||||35.1%|
@ -66,7 +66,7 @@ weight: 1
|0219|Contains Duplicate II|[Go]({{< relref "/ChapterFour/0200~0299/0219.Contains-Duplicate-II.md" >}})|Easy| O(n)| O(n)||38.6%|
|0228|Summary Ranges|[Go]({{< relref "/ChapterFour/0200~0299/0228.Summary-Ranges.md" >}})|Easy||||42.3%|
|0229|Majority Element II|[Go]({{< relref "/ChapterFour/0200~0299/0229.Majority-Element-II.md" >}})|Medium||||38.7%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||53.7%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||53.8%|
|0283|Move Zeroes|[Go]({{< relref "/ChapterFour/0200~0299/0283.Move-Zeroes.md" >}})|Easy| O(n)| O(1)||58.5%|
|0287|Find the Duplicate Number|[Go]({{< relref "/ChapterFour/0200~0299/0287.Find-the-Duplicate-Number.md" >}})|Medium| O(n)| O(1)|❤️|57.4%|
|0414|Third Maximum Number|[Go]({{< relref "/ChapterFour/0400~0499/0414.Third-Maximum-Number.md" >}})|Easy||||30.7%|
@ -75,12 +75,13 @@ weight: 1
|0485|Max Consecutive Ones|[Go]({{< relref "/ChapterFour/0400~0499/0485.Max-Consecutive-Ones.md" >}})|Easy||||53.0%|
|0509|Fibonacci Number|[Go]({{< relref "/ChapterFour/0500~0599/0509.Fibonacci-Number.md" >}})|Easy||||67.4%|
|0532|K-diff Pairs in an Array|[Go]({{< relref "/ChapterFour/0500~0599/0532.K-diff-Pairs-in-an-Array.md" >}})|Medium| O(n)| O(n)||35.1%|
|0561|Array Partition I|[Go]({{< relref "/ChapterFour/0500~0599/0561.Array-Partition-I.md" >}})|Easy||||73.1%|
|0561|Array Partition I|[Go]({{< relref "/ChapterFour/0500~0599/0561.Array-Partition-I.md" >}})|Easy||||73.2%|
|0566|Reshape the Matrix|[Go]({{< relref "/ChapterFour/0500~0599/0566.Reshape-the-Matrix.md" >}})|Easy| O(n^2)| O(n^2)||61.0%|
|0605|Can Place Flowers|[Go]({{< relref "/ChapterFour/0600~0699/0605.Can-Place-Flowers.md" >}})|Easy||||31.8%|
|0628|Maximum Product of Three Numbers|[Go]({{< relref "/ChapterFour/0600~0699/0628.Maximum-Product-of-Three-Numbers.md" >}})|Easy| O(n)| O(1)||46.9%|
|0643|Maximum Average Subarray I|[Go]({{< relref "/ChapterFour/0600~0699/0643.Maximum-Average-Subarray-I.md" >}})|Easy||||42.0%|
|0661|Image Smoother|[Go]({{< relref "/ChapterFour/0600~0699/0661.Image-Smoother.md" >}})|Easy||||52.3%|
|0661|Image Smoother|[Go]({{< relref "/ChapterFour/0600~0699/0661.Image-Smoother.md" >}})|Easy||||52.2%|
|0665|Non-decreasing Array|[Go]({{< relref "/ChapterFour/0600~0699/0665.Non-decreasing-Array.md" >}})|Medium||||19.7%|
|0674|Longest Continuous Increasing Subsequence|[Go]({{< relref "/ChapterFour/0600~0699/0674.Longest-Continuous-Increasing-Subsequence.md" >}})|Easy||||46.1%|
|0695|Max Area of Island|[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})|Medium||||64.6%|
|0697|Degree of an Array|[Go]({{< relref "/ChapterFour/0600~0699/0697.Degree-of-an-Array.md" >}})|Easy||||54.4%|
@ -119,9 +120,9 @@ weight: 1
|1089|Duplicate Zeros|[Go]({{< relref "/ChapterFour/1000~1099/1089.Duplicate-Zeros.md" >}})|Easy||||51.9%|
|1122|Relative Sort Array|[Go]({{< relref "/ChapterFour/1100~1199/1122.Relative-Sort-Array.md" >}})|Easy||||68.1%|
|1128|Number of Equivalent Domino Pairs|[Go]({{< relref "/ChapterFour/1100~1199/1128.Number-of-Equivalent-Domino-Pairs.md" >}})|Easy||||46.6%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.7%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.6%|
|1160|Find Words That Can Be Formed by Characters|[Go]({{< relref "/ChapterFour/1100~1199/1160.Find-Words-That-Can-Be-Formed-by-Characters.md" >}})|Easy||||67.9%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.5%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.6%|
|1184|Distance Between Bus Stops|[Go]({{< relref "/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md" >}})|Easy||||54.1%|
|1185|Day of the Week|[Go]({{< relref "/ChapterFour/1100~1199/1185.Day-of-the-Week.md" >}})|Easy||||61.6%|
|1200|Minimum Absolute Difference|[Go]({{< relref "/ChapterFour/1200~1299/1200.Minimum-Absolute-Difference.md" >}})|Easy||||66.9%|
@ -143,6 +144,7 @@ weight: 1
|1380|Lucky Numbers in a Matrix|[Go]({{< relref "/ChapterFour/1300~1399/1380.Lucky-Numbers-in-a-Matrix.md" >}})|Easy||||70.8%|
|1385|Find the Distance Value Between Two Arrays|[Go]({{< relref "/ChapterFour/1300~1399/1385.Find-the-Distance-Value-Between-Two-Arrays.md" >}})|Easy||||66.4%|
|1389|Create Target Array in the Given Order|[Go]({{< relref "/ChapterFour/1300~1399/1389.Create-Target-Array-in-the-Given-Order.md" >}})|Easy||||84.8%|
|1423|Maximum Points You Can Obtain from Cards|[Go]({{< relref "/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards.md" >}})|Medium||||46.6%|
|1437|Check If All 1's Are at Least Length K Places Away|[Go]({{< relref "/ChapterFour/1400~1499/1437.Check-If-All-1s-Are-at-Least-Length-K-Places-Away.md" >}})|Easy||||62.7%|
|1464|Maximum Product of Two Elements in an Array|[Go]({{< relref "/ChapterFour/1400~1499/1464.Maximum-Product-of-Two-Elements-in-an-Array.md" >}})|Easy||||77.2%|
|1470|Shuffle the Array|[Go]({{< relref "/ChapterFour/1400~1499/1470.Shuffle-the-Array.md" >}})|Easy||||88.4%|
@ -151,7 +153,7 @@ weight: 1
|1539|Kth Missing Positive Number|[Go]({{< relref "/ChapterFour/1500~1599/1539.Kth-Missing-Positive-Number.md" >}})|Easy||||55.1%|
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.2%|
|1646|Get Maximum in Generated Array|[Go]({{< relref "/ChapterFour/1600~1699/1646.Get-Maximum-in-Generated-Array.md" >}})|Easy||||53.5%|
|1652|Defuse the Bomb|[Go]({{< relref "/ChapterFour/1600~1699/1652.Defuse-the-Bomb.md" >}})|Easy||||62.9%|
|1652|Defuse the Bomb|[Go]({{< relref "/ChapterFour/1600~1699/1652.Defuse-the-Bomb.md" >}})|Easy||||63.0%|
|1656|Design an Ordered Stream|[Go]({{< relref "/ChapterFour/1600~1699/1656.Design-an-Ordered-Stream.md" >}})|Easy||||82.2%|
|1672|Richest Customer Wealth|[Go]({{< relref "/ChapterFour/1600~1699/1672.Richest-Customer-Wealth.md" >}})|Easy||||88.4%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -131,10 +131,10 @@ func updateMatrix_BFS(matrix [][]int) [][]int {
|0996|Number of Squareful Arrays|[Go]({{< relref "/ChapterFour/0900~0999/0996.Number-of-Squareful-Arrays.md" >}})|Hard| O(n log n)| O(n) ||48.3%|
|1079|Letter Tile Possibilities|[Go]({{< relref "/ChapterFour/1000~1099/1079.Letter-Tile-Possibilities.md" >}})|Medium| O(n^2)| O(1)|❤️|75.9%|
|1641|Count Sorted Vowel Strings|[Go]({{< relref "/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings.md" >}})|Medium||||76.9%|
|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.4%|
|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.3%|
|1659|Maximize Grid Happiness|[Go]({{< relref "/ChapterFour/1600~1699/1659.Maximize-Grid-Happiness.md" >}})|Hard||||35.3%|
|1681|Minimum Incompatibility|[Go]({{< relref "/ChapterFour/1600~1699/1681.Minimum-Incompatibility.md" >}})|Hard||||35.4%|
|1688|Count of Matches in Tournament|[Go]({{< relref "/ChapterFour/1600~1699/1688.Count-of-Matches-in-Tournament.md" >}})|Easy||||82.6%|
|1688|Count of Matches in Tournament|[Go]({{< relref "/ChapterFour/1600~1699/1688.Count-of-Matches-in-Tournament.md" >}})|Easy||||82.5%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -147,7 +147,7 @@ func peakIndexInMountainArray(A []int) int {
|0174|Dungeon Game|[Go]({{< relref "/ChapterFour/0100~0199/0174.Dungeon-Game.md" >}})|Hard||||33.2%|
|0209|Minimum Size Subarray Sum|[Go]({{< relref "/ChapterFour/0200~0299/0209.Minimum-Size-Subarray-Sum.md" >}})|Medium| O(n)| O(1)||39.4%|
|0222|Count Complete Tree Nodes|[Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}})|Medium| O(n)| O(1)||49.1%|
|0230|Kth Smallest Element in a BST|[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})|Medium| O(n)| O(1)||62.4%|
|0230|Kth Smallest Element in a BST|[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})|Medium| O(n)| O(1)||62.5%|
|0240|Search a 2D Matrix II|[Go]({{< relref "/ChapterFour/0200~0299/0240.Search-a-2D-Matrix-II.md" >}})|Medium||||44.4%|
|0275|H-Index II|[Go]({{< relref "/ChapterFour/0200~0299/0275.H-Index-II.md" >}})|Medium||||36.3%|
|0287|Find the Duplicate Number|[Go]({{< relref "/ChapterFour/0200~0299/0287.Find-the-Duplicate-Number.md" >}})|Medium| O(n)| O(1)|❤️|57.4%|
@ -184,13 +184,13 @@ func peakIndexInMountainArray(A []int) int {
|0875|Koko Eating Bananas|[Go]({{< relref "/ChapterFour/0800~0899/0875.Koko-Eating-Bananas.md" >}})|Medium||||53.4%|
|0878|Nth Magical Number|[Go]({{< relref "/ChapterFour/0800~0899/0878.Nth-Magical-Number.md" >}})|Hard||||28.8%|
|0887|Super Egg Drop|[Go]({{< relref "/ChapterFour/0800~0899/0887.Super-Egg-Drop.md" >}})|Hard||||27.1%|
|0911|Online Election|[Go]({{< relref "/ChapterFour/0900~0999/0911.Online-Election.md" >}})|Medium||||51.2%|
|0911|Online Election|[Go]({{< relref "/ChapterFour/0900~0999/0911.Online-Election.md" >}})|Medium||||51.3%|
|0927|Three Equal Parts|[Go]({{< relref "/ChapterFour/0900~0999/0927.Three-Equal-Parts.md" >}})|Hard||||34.6%|
|0981|Time Based Key-Value Store|[Go]({{< relref "/ChapterFour/0900~0999/0981.Time-Based-Key-Value-Store.md" >}})|Medium||||54.1%|
|1011|Capacity To Ship Packages Within D Days|[Go]({{< relref "/ChapterFour/1000~1099/1011.Capacity-To-Ship-Packages-Within-D-Days.md" >}})|Medium||||59.7%|
|1111|Maximum Nesting Depth of Two Valid Parentheses Strings|[Go]({{< relref "/ChapterFour/1100~1199/1111.Maximum-Nesting-Depth-of-Two-Valid-Parentheses-Strings.md" >}})|Medium||||72.8%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.7%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.5%|
|1111|Maximum Nesting Depth of Two Valid Parentheses Strings|[Go]({{< relref "/ChapterFour/1100~1199/1111.Maximum-Nesting-Depth-of-Two-Valid-Parentheses-Strings.md" >}})|Medium||||72.7%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.6%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.6%|
|1201|Ugly Number III|[Go]({{< relref "/ChapterFour/1200~1299/1201.Ugly-Number-III.md" >}})|Medium||||26.4%|
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.4%|
|1283|Find the Smallest Divisor Given a Threshold|[Go]({{< relref "/ChapterFour/1200~1299/1283.Find-the-Smallest-Divisor-Given-a-Threshold.md" >}})|Medium||||49.4%|

View File

@ -54,7 +54,7 @@ X & ~X = 0
|0201|Bitwise AND of Numbers Range|[Go]({{< relref "/ChapterFour/0200~0299/0201.Bitwise-AND-of-Numbers-Range.md" >}})|Medium| O(n)| O(1)|❤️|39.6%|
|0231|Power of Two|[Go]({{< relref "/ChapterFour/0200~0299/0231.Power-of-Two.md" >}})|Easy| O(1)| O(1)||43.8%|
|0260|Single Number III|[Go]({{< relref "/ChapterFour/0200~0299/0260.Single-Number-III.md" >}})|Medium| O(n)| O(1)|❤️|65.3%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy| O(n)| O(1)||53.7%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy| O(n)| O(1)||53.8%|
|0318|Maximum Product of Word Lengths|[Go]({{< relref "/ChapterFour/0300~0399/0318.Maximum-Product-of-Word-Lengths.md" >}})|Medium| O(n)| O(1)||52.2%|
|0338|Counting Bits|[Go]({{< relref "/ChapterFour/0300~0399/0338.Counting-Bits.md" >}})|Medium| O(n)| O(n)||70.3%|
|0342|Power of Four|[Go]({{< relref "/ChapterFour/0300~0399/0342.Power-of-Four.md" >}})|Easy| O(n)| O(1)||41.7%|
@ -64,8 +64,8 @@ X & ~X = 0
|0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium| O(n)| O(1)||33.4%|
|0401|Binary Watch|[Go]({{< relref "/ChapterFour/0400~0499/0401.Binary-Watch.md" >}})|Easy| O(1)| O(1)||48.4%|
|0405|Convert a Number to Hexadecimal|[Go]({{< relref "/ChapterFour/0400~0499/0405.Convert-a-Number-to-Hexadecimal.md" >}})|Easy| O(n)| O(1)||44.4%|
|0421|Maximum XOR of Two Numbers in an Array|[Go]({{< relref "/ChapterFour/0400~0499/0421.Maximum-XOR-of-Two-Numbers-in-an-Array.md" >}})|Medium| O(n)| O(1)|❤️|54.0%|
|0461|Hamming Distance|[Go]({{< relref "/ChapterFour/0400~0499/0461.Hamming-Distance.md" >}})|Easy| O(n)| O(1)||73.1%|
|0421|Maximum XOR of Two Numbers in an Array|[Go]({{< relref "/ChapterFour/0400~0499/0421.Maximum-XOR-of-Two-Numbers-in-an-Array.md" >}})|Medium| O(n)| O(1)|❤️|54.1%|
|0461|Hamming Distance|[Go]({{< relref "/ChapterFour/0400~0499/0461.Hamming-Distance.md" >}})|Easy| O(n)| O(1)||73.2%|
|0476|Number Complement|[Go]({{< relref "/ChapterFour/0400~0499/0476.Number-Complement.md" >}})|Easy| O(n)| O(1)||65.1%|
|0477|Total Hamming Distance|[Go]({{< relref "/ChapterFour/0400~0499/0477.Total-Hamming-Distance.md" >}})|Medium| O(n)| O(1)||50.6%|
|0693|Binary Number with Alternating Bits|[Go]({{< relref "/ChapterFour/0600~0699/0693.Binary-Number-with-Alternating-Bits.md" >}})|Easy| O(n)| O(1)|❤️|59.8%|

View File

@ -32,8 +32,8 @@ weight: 10
|0987|Vertical Order Traversal of a Binary Tree|[Go]({{< relref "/ChapterFour/0900~0999/0987.Vertical-Order-Traversal-of-a-Binary-Tree.md" >}})|Hard||||38.7%|
|0993|Cousins in Binary Tree|[Go]({{< relref "/ChapterFour/0900~0999/0993.Cousins-in-Binary-Tree.md" >}})|Easy| O(n)| O(1)||52.3%|
|1306|Jump Game III|[Go]({{< relref "/ChapterFour/1300~1399/1306.Jump-Game-III.md" >}})|Medium||||62.6%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.3%|
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.2%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.4%|
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.1%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -17,7 +17,7 @@ weight: 9
|0104|Maximum Depth of Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0104.Maximum-Depth-of-Binary-Tree.md" >}})|Easy| O(n)| O(1)||67.9%|
|0105|Construct Binary Tree from Preorder and Inorder Traversal|[Go]({{< relref "/ChapterFour/0100~0199/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal.md" >}})|Medium||||51.6%|
|0106|Construct Binary Tree from Inorder and Postorder Traversal|[Go]({{< relref "/ChapterFour/0100~0199/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal.md" >}})|Medium||||49.5%|
|0108|Convert Sorted Array to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}})|Easy| O(n)| O(1)||60.2%|
|0108|Convert Sorted Array to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}})|Easy| O(n)| O(1)||60.3%|
|0109|Convert Sorted List to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0109.Convert-Sorted-List-to-Binary-Search-Tree.md" >}})|Medium| O(log n)| O(n)||50.1%|
|0110|Balanced Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0110.Balanced-Binary-Tree.md" >}})|Easy| O(n)| O(1)||44.7%|
|0111|Minimum Depth of Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}})|Easy| O(n)| O(1)||39.4%|
@ -48,7 +48,7 @@ weight: 9
|0547|Number of Provinces|[Go]({{< relref "/ChapterFour/0500~0599/0547.Number-of-Provinces.md" >}})|Medium||||60.4%|
|0563|Binary Tree Tilt|[Go]({{< relref "/ChapterFour/0500~0599/0563.Binary-Tree-Tilt.md" >}})|Easy||||52.9%|
|0638|Shopping Offers|[Go]({{< relref "/ChapterFour/0600~0699/0638.Shopping-Offers.md" >}})|Medium||||52.8%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||32.9%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||33.0%|
|0695|Max Area of Island|[Go]({{< relref "/ChapterFour/0600~0699/0695.Max-Area-of-Island.md" >}})|Medium||||64.6%|
|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium||||51.6%|
|0733|Flood Fill|[Go]({{< relref "/ChapterFour/0700~0799/0733.Flood-Fill.md" >}})|Easy||||55.9%|
@ -80,10 +80,10 @@ weight: 9
|1123|Lowest Common Ancestor of Deepest Leaves|[Go]({{< relref "/ChapterFour/1100~1199/1123.Lowest-Common-Ancestor-of-Deepest-Leaves.md" >}})|Medium||||68.0%|
|1145|Binary Tree Coloring Game|[Go]({{< relref "/ChapterFour/1100~1199/1145.Binary-Tree-Coloring-Game.md" >}})|Medium||||51.4%|
|1203|Sort Items by Groups Respecting Dependencies|[Go]({{< relref "/ChapterFour/1200~1299/1203.Sort-Items-by-Groups-Respecting-Dependencies.md" >}})|Hard||||48.9%|
|1254|Number of Closed Islands|[Go]({{< relref "/ChapterFour/1200~1299/1254.Number-of-Closed-Islands.md" >}})|Medium||||61.5%|
|1254|Number of Closed Islands|[Go]({{< relref "/ChapterFour/1200~1299/1254.Number-of-Closed-Islands.md" >}})|Medium||||61.6%|
|1302|Deepest Leaves Sum|[Go]({{< relref "/ChapterFour/1300~1399/1302.Deepest-Leaves-Sum.md" >}})|Medium||||84.2%|
|1306|Jump Game III|[Go]({{< relref "/ChapterFour/1300~1399/1306.Jump-Game-III.md" >}})|Medium||||62.6%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.3%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.4%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -54,9 +54,11 @@ weight: 7
|1074|Number of Submatrices That Sum to Target|[Go]({{< relref "/ChapterFour/1000~1099/1074.Number-of-Submatrices-That-Sum-to-Target.md" >}})|Hard||||61.7%|
|1105|Filling Bookcase Shelves|[Go]({{< relref "/ChapterFour/1100~1199/1105.Filling-Bookcase-Shelves.md" >}})|Medium||||57.5%|
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.4%|
|1423|Maximum Points You Can Obtain from Cards|[Go]({{< relref "/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards.md" >}})|Medium||||46.6%|
|1463|Cherry Pickup II|[Go]({{< relref "/ChapterFour/1400~1499/1463.Cherry-Pickup-II.md" >}})|Hard||||69.3%|
|1641|Count Sorted Vowel Strings|[Go]({{< relref "/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings.md" >}})|Medium||||76.9%|
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.2%|
|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.4%|
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.1%|
|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.3%|
|1659|Maximize Grid Happiness|[Go]({{< relref "/ChapterFour/1600~1699/1659.Maximize-Grid-Happiness.md" >}})|Hard||||35.3%|
|1664|Ways to Make a Fair Array|[Go]({{< relref "/ChapterFour/1600~1699/1664.Ways-to-Make-a-Fair-Array.md" >}})|Medium||||60.6%|
|1690|Stone Game VII|[Go]({{< relref "/ChapterFour/1600~1699/1690.Stone-Game-VII.md" >}})|Medium||||47.6%|

View File

@ -15,11 +15,11 @@ weight: 13
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|0036|Valid Sudoku|[Go]({{< relref "/ChapterFour/0001~0099/0036.Valid-Sudoku.md" >}})|Medium| O(n^2)| O(n^2)||50.4%|
|0037|Sudoku Solver|[Go]({{< relref "/ChapterFour/0001~0099/0037.Sudoku-Solver.md" >}})|Hard| O(n^2)| O(n^2)|❤️|46.4%|
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.1%|
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.2%|
|0076|Minimum Window Substring|[Go]({{< relref "/ChapterFour/0001~0099/0076.Minimum-Window-Substring.md" >}})|Hard| O(n)| O(n)|❤️|35.9%|
|0094|Binary Tree Inorder Traversal|[Go]({{< relref "/ChapterFour/0001~0099/0094.Binary-Tree-Inorder-Traversal.md" >}})|Medium| O(n)| O(1)||65.7%|
|0136|Single Number|[Go]({{< relref "/ChapterFour/0100~0199/0136.Single-Number.md" >}})|Easy||||66.5%|
|0138|Copy List with Random Pointer|[Go]({{< relref "/ChapterFour/0100~0199/0138.Copy-List-with-Random-Pointer.md" >}})|Medium| O(n)| O(1)||40.6%|
|0138|Copy List with Random Pointer|[Go]({{< relref "/ChapterFour/0100~0199/0138.Copy-List-with-Random-Pointer.md" >}})|Medium| O(n)| O(1)||40.7%|
|0187|Repeated DNA Sequences|[Go]({{< relref "/ChapterFour/0100~0199/0187.Repeated-DNA-Sequences.md" >}})|Medium||||41.4%|
|0202|Happy Number|[Go]({{< relref "/ChapterFour/0200~0299/0202.Happy-Number.md" >}})|Easy| O(log n)| O(1)||51.2%|
|0204|Count Primes|[Go]({{< relref "/ChapterFour/0200~0299/0204.Count-Primes.md" >}})|Easy||||32.2%|
@ -60,7 +60,7 @@ weight: 13
|0771|Jewels and Stones|[Go]({{< relref "/ChapterFour/0700~0799/0771.Jewels-and-Stones.md" >}})|Easy||||86.9%|
|0781|Rabbits in Forest|[Go]({{< relref "/ChapterFour/0700~0799/0781.Rabbits-in-Forest.md" >}})|Medium||||55.5%|
|0811|Subdomain Visit Count|[Go]({{< relref "/ChapterFour/0800~0899/0811.Subdomain-Visit-Count.md" >}})|Easy||||71.4%|
|0884|Uncommon Words from Two Sentences|[Go]({{< relref "/ChapterFour/0800~0899/0884.Uncommon-Words-from-Two-Sentences.md" >}})|Easy||||64.0%|
|0884|Uncommon Words from Two Sentences|[Go]({{< relref "/ChapterFour/0800~0899/0884.Uncommon-Words-from-Two-Sentences.md" >}})|Easy||||64.1%|
|0895|Maximum Frequency Stack|[Go]({{< relref "/ChapterFour/0800~0899/0895.Maximum-Frequency-Stack.md" >}})|Hard| O(n)| O(n) ||62.3%|
|0930|Binary Subarrays With Sum|[Go]({{< relref "/ChapterFour/0900~0999/0930.Binary-Subarrays-With-Sum.md" >}})|Medium| O(n)| O(n) |❤️|44.5%|
|0953|Verifying an Alien Dictionary|[Go]({{< relref "/ChapterFour/0900~0999/0953.Verifying-an-Alien-Dictionary.md" >}})|Easy||||52.3%|

View File

@ -35,7 +35,7 @@ weight: 4
|0086|Partition List|[Go]({{< relref "/ChapterFour/0001~0099/0086.Partition-List.md" >}})|Medium| O(n)| O(1)|❤️|43.3%|
|0092|Reverse Linked List II|[Go]({{< relref "/ChapterFour/0001~0099/0092.Reverse-Linked-List-II.md" >}})|Medium| O(n)| O(1)|❤️|40.5%|
|0109|Convert Sorted List to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0109.Convert-Sorted-List-to-Binary-Search-Tree.md" >}})|Medium| O(log n)| O(n)||50.1%|
|0138|Copy List with Random Pointer|[Go]({{< relref "/ChapterFour/0100~0199/0138.Copy-List-with-Random-Pointer.md" >}})|Medium||||40.6%|
|0138|Copy List with Random Pointer|[Go]({{< relref "/ChapterFour/0100~0199/0138.Copy-List-with-Random-Pointer.md" >}})|Medium||||40.7%|
|0141|Linked List Cycle|[Go]({{< relref "/ChapterFour/0100~0199/0141.Linked-List-Cycle.md" >}})|Easy| O(n)| O(1)|❤️|42.8%|
|0142|Linked List Cycle II|[Go]({{< relref "/ChapterFour/0100~0199/0142.Linked-List-Cycle-II.md" >}})|Medium| O(n)| O(1)|❤️|39.6%|
|0143|Reorder List|[Go]({{< relref "/ChapterFour/0100~0199/0143.Reorder-List.md" >}})|Medium| O(n)| O(1)|❤️|40.5%|
@ -50,13 +50,13 @@ weight: 4
|0445|Add Two Numbers II|[Go]({{< relref "/ChapterFour/0400~0499/0445.Add-Two-Numbers-II.md" >}})|Medium| O(n)| O(n)||56.2%|
|0707|Design Linked List|[Go]({{< relref "/ChapterFour/0700~0799/0707.Design-Linked-List.md" >}})|Medium| O(n)| O(1)||25.8%|
|0725|Split Linked List in Parts|[Go]({{< relref "/ChapterFour/0700~0799/0725.Split-Linked-List-in-Parts.md" >}})|Medium| O(n)| O(1)||52.9%|
|0817|Linked List Components|[Go]({{< relref "/ChapterFour/0800~0899/0817.Linked-List-Components.md" >}})|Medium| O(n)| O(1)||57.7%|
|0817|Linked List Components|[Go]({{< relref "/ChapterFour/0800~0899/0817.Linked-List-Components.md" >}})|Medium| O(n)| O(1)||57.8%|
|0876|Middle of the Linked List|[Go]({{< relref "/ChapterFour/0800~0899/0876.Middle-of-the-Linked-List.md" >}})|Easy| O(n)| O(1)|❤️|69.1%|
|1019|Next Greater Node In Linked List|[Go]({{< relref "/ChapterFour/1000~1099/1019.Next-Greater-Node-In-Linked-List.md" >}})|Medium| O(n)| O(1)||58.2%|
|1171|Remove Zero Sum Consecutive Nodes from Linked List|[Go]({{< relref "/ChapterFour/1100~1199/1171.Remove-Zero-Sum-Consecutive-Nodes-from-Linked-List.md" >}})|Medium||||41.4%|
|1290|Convert Binary Number in a Linked List to Integer|[Go]({{< relref "/ChapterFour/1200~1299/1290.Convert-Binary-Number-in-a-Linked-List-to-Integer.md" >}})|Easy||||81.8%|
|1669|Merge In Between Linked Lists|[Go]({{< relref "/ChapterFour/1600~1699/1669.Merge-In-Between-Linked-Lists.md" >}})|Medium||||77.1%|
|1670|Design Front Middle Back Queue|[Go]({{< relref "/ChapterFour/1600~1699/1670.Design-Front-Middle-Back-Queue.md" >}})|Medium||||54.6%|
|1669|Merge In Between Linked Lists|[Go]({{< relref "/ChapterFour/1600~1699/1669.Merge-In-Between-Linked-Lists.md" >}})|Medium||||77.0%|
|1670|Design Front Middle Back Queue|[Go]({{< relref "/ChapterFour/1600~1699/1670.Design-Front-Middle-Back-Queue.md" >}})|Medium||||54.5%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -28,7 +28,7 @@ weight: 12
|0231|Power of Two|[Go]({{< relref "/ChapterFour/0200~0299/0231.Power-of-Two.md" >}})|Easy| O(1)| O(1)||43.8%|
|0258|Add Digits|[Go]({{< relref "/ChapterFour/0200~0299/0258.Add-Digits.md" >}})|Easy||||58.4%|
|0263|Ugly Number|[Go]({{< relref "/ChapterFour/0200~0299/0263.Ugly-Number.md" >}})|Easy| O(log n)| O(1)||41.7%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||53.7%|
|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||53.8%|
|0326|Power of Three|[Go]({{< relref "/ChapterFour/0300~0399/0326.Power-of-Three.md" >}})|Easy| O(1)| O(1)||42.1%|
|0343|Integer Break|[Go]({{< relref "/ChapterFour/0300~0399/0343.Integer-Break.md" >}})|Medium| O(n^2)| O(n)||51.2%|
|0357|Count Numbers with Unique Digits|[Go]({{< relref "/ChapterFour/0300~0399/0357.Count-Numbers-with-Unique-Digits.md" >}})|Medium| O(1)| O(1)||48.8%|

View File

@ -46,7 +46,7 @@ weight: 18
|0715|Range Module|[Go]({{< relref "/ChapterFour/0700~0799/0715.Range-Module.md" >}})|Hard| O(log n)| O(n)|❤️|40.2%|
|0732|My Calendar III|[Go]({{< relref "/ChapterFour/0700~0799/0732.My-Calendar-III.md" >}})|Hard| O(log n)| O(n)|❤️|61.7%|
|0850|Rectangle Area II|[Go]({{< relref "/ChapterFour/0800~0899/0850.Rectangle-Area-II.md" >}})|Hard| O(n log n)| O(n)|❤️|48.3%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard| O(log n)| O(n)|❤️|39.7%|
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard| O(log n)| O(n)|❤️|39.6%|
|1649|Create Sorted Array through Instructions|[Go]({{< relref "/ChapterFour/1600~1699/1649.Create-Sorted-Array-through-Instructions.md" >}})|Hard||||36.3%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -37,18 +37,17 @@ weight: 17
|0567|Permutation in String|[Go]({{< relref "/ChapterFour/0500~0599/0567.Permutation-in-String.md" >}})|Medium| O(n)| O(1)|❤️|44.6%|
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium| O(n)| O(1)|❤️|46.6%|
|0992|Subarrays with K Different Integers|[Go]({{< relref "/ChapterFour/0900~0999/0992.Subarrays-with-K-Different-Integers.md" >}})|Hard| O(n)| O(n)|❤️|50.6%|
|0995|Minimum Number of K Consecutive Bit Flips|[Go]({{< relref "/ChapterFour/0900~0999/0995.Minimum-Number-of-K-Consecutive-Bit-Flips.md" >}})|Hard| O(n)| O(1)|❤️|49.7%|
|0995|Minimum Number of K Consecutive Bit Flips|[Go]({{< relref "/ChapterFour/0900~0999/0995.Minimum-Number-of-K-Consecutive-Bit-Flips.md" >}})|Hard| O(n)| O(1)|❤️|49.8%|
|1004|Max Consecutive Ones III|[Go]({{< relref "/ChapterFour/1000~1099/1004.Max-Consecutive-Ones-III.md" >}})|Medium| O(n)| O(1) ||60.7%|
|1040|Moving Stones Until Consecutive II|[Go]({{< relref "/ChapterFour/1000~1099/1040.Moving-Stones-Until-Consecutive-II.md" >}})|Medium| O(n log n)| O(1) |❤️|54.1%|
|1052|Grumpy Bookstore Owner|[Go]({{< relref "/ChapterFour/1000~1099/1052.Grumpy-Bookstore-Owner.md" >}})|Medium| O(n log n)| O(1) ||55.8%|
|1074|Number of Submatrices That Sum to Target|[Go]({{< relref "/ChapterFour/1000~1099/1074.Number-of-Submatrices-That-Sum-to-Target.md" >}})|Hard| O(n^3)| O(n) |❤️|61.7%|
|1208|Get Equal Substrings Within Budget|[Go]({{< relref "/ChapterFour/1200~1299/1208.Get-Equal-Substrings-Within-Budget.md" >}})|Medium||||43.9%|
|1423|Maximum Points You Can Obtain from Cards|[Go]({{< relref "/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards.md" >}})|Medium||||46.6%|
|1658|Minimum Operations to Reduce X to Zero|[Go]({{< relref "/ChapterFour/1600~1699/1658.Minimum-Operations-to-Reduce-X-to-Zero.md" >}})|Medium||||33.4%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Union_Find/">⬅️上一页</a></p>

View File

@ -29,7 +29,7 @@ weight: 14
|0242|Valid Anagram|[Go]({{< relref "/ChapterFour/0200~0299/0242.Valid-Anagram.md" >}})|Easy| O(n)| O(n) ||58.5%|
|0274|H-Index|[Go]({{< relref "/ChapterFour/0200~0299/0274.H-Index.md" >}})|Medium| O(n)| O(n) ||36.3%|
|0315|Count of Smaller Numbers After Self|[Go]({{< relref "/ChapterFour/0300~0399/0315.Count-of-Smaller-Numbers-After-Self.md" >}})|Hard||||42.5%|
|0324|Wiggle Sort II|[Go]({{< relref "/ChapterFour/0300~0399/0324.Wiggle-Sort-II.md" >}})|Medium| O(n)| O(n)|❤️|30.6%|
|0324|Wiggle Sort II|[Go]({{< relref "/ChapterFour/0300~0399/0324.Wiggle-Sort-II.md" >}})|Medium| O(n)| O(n)|❤️|30.7%|
|0327|Count of Range Sum|[Go]({{< relref "/ChapterFour/0300~0399/0327.Count-of-Range-Sum.md" >}})|Hard||||36.0%|
|0349|Intersection of Two Arrays|[Go]({{< relref "/ChapterFour/0300~0399/0349.Intersection-of-Two-Arrays.md" >}})|Easy| O(n)| O(n) ||64.7%|
|0350|Intersection of Two Arrays II|[Go]({{< relref "/ChapterFour/0300~0399/0350.Intersection-of-Two-Arrays-II.md" >}})|Easy| O(n)| O(n) ||52.0%|

View File

@ -49,11 +49,11 @@ weight: 5
|0895|Maximum Frequency Stack|[Go]({{< relref "/ChapterFour/0800~0899/0895.Maximum-Frequency-Stack.md" >}})|Hard| O(n)| O(n) ||62.3%|
|0901|Online Stock Span|[Go]({{< relref "/ChapterFour/0900~0999/0901.Online-Stock-Span.md" >}})|Medium| O(n)| O(n) ||61.3%|
|0907|Sum of Subarray Minimums|[Go]({{< relref "/ChapterFour/0900~0999/0907.Sum-of-Subarray-Minimums.md" >}})|Medium| O(n)| O(n)|❤️|33.1%|
|0921|Minimum Add to Make Parentheses Valid|[Go]({{< relref "/ChapterFour/0900~0999/0921.Minimum-Add-to-Make-Parentheses-Valid.md" >}})|Medium| O(n)| O(n)||74.8%|
|0921|Minimum Add to Make Parentheses Valid|[Go]({{< relref "/ChapterFour/0900~0999/0921.Minimum-Add-to-Make-Parentheses-Valid.md" >}})|Medium| O(n)| O(n)||74.7%|
|0946|Validate Stack Sequences|[Go]({{< relref "/ChapterFour/0900~0999/0946.Validate-Stack-Sequences.md" >}})|Medium| O(n)| O(n)||63.6%|
|1003|Check If Word Is Valid After Substitutions|[Go]({{< relref "/ChapterFour/1000~1099/1003.Check-If-Word-Is-Valid-After-Substitutions.md" >}})|Medium| O(n)| O(1)||56.3%|
|1019|Next Greater Node In Linked List|[Go]({{< relref "/ChapterFour/1000~1099/1019.Next-Greater-Node-In-Linked-List.md" >}})|Medium| O(n)| O(1)||58.2%|
|1021|Remove Outermost Parentheses|[Go]({{< relref "/ChapterFour/1000~1099/1021.Remove-Outermost-Parentheses.md" >}})|Easy| O(n)| O(1)||78.9%|
|1021|Remove Outermost Parentheses|[Go]({{< relref "/ChapterFour/1000~1099/1021.Remove-Outermost-Parentheses.md" >}})|Easy| O(n)| O(1)||79.0%|
|1047|Remove All Adjacent Duplicates In String|[Go]({{< relref "/ChapterFour/1000~1099/1047.Remove-All-Adjacent-Duplicates-In-String.md" >}})|Easy| O(n)| O(1)||70.6%|
|1673|Find the Most Competitive Subsequence|[Go]({{< relref "/ChapterFour/1600~1699/1673.Find-the-Most-Competitive-Subsequence.md" >}})|Medium||||45.2%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -14,9 +14,9 @@ weight: 2
|0017|Letter Combinations of a Phone Number|[Go]({{< relref "/ChapterFour/0001~0099/0017.Letter-Combinations-of-a-Phone-Number.md" >}})|Medium| O(log n)| O(1)||49.0%|
|0020|Valid Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0020.Valid-Parentheses.md" >}})|Easy| O(log n)| O(1)||39.8%|
|0022|Generate Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0022.Generate-Parentheses.md" >}})|Medium| O(log n)| O(1)||65.1%|
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.1%|
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.2%|
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.1%|
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.2%|
|0067|Add Binary|[Go]({{< relref "/ChapterFour/0001~0099/0067.Add-Binary.md" >}})|Easy||||46.8%|
|0071|Simplify Path|[Go]({{< relref "/ChapterFour/0001~0099/0071.Simplify-Path.md" >}})|Medium| O(n)| O(n)||34.6%|
|0076|Minimum Window Substring|[Go]({{< relref "/ChapterFour/0001~0099/0076.Minimum-Window-Substring.md" >}})|Hard| O(n)| O(n)|❤️|35.9%|
@ -40,18 +40,18 @@ weight: 2
|0925|Long Pressed Name|[Go]({{< relref "/ChapterFour/0900~0999/0925.Long-Pressed-Name.md" >}})|Easy| O(n)| O(1)||38.1%|
|1003|Check If Word Is Valid After Substitutions|[Go]({{< relref "/ChapterFour/1000~1099/1003.Check-If-Word-Is-Valid-After-Substitutions.md" >}})|Medium| O(n)| O(1)||56.3%|
|1108|Defanging an IP Address|[Go]({{< relref "/ChapterFour/1100~1199/1108.Defanging-an-IP-Address.md" >}})|Easy||||88.4%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.5%|
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.6%|
|1189|Maximum Number of Balloons|[Go]({{< relref "/ChapterFour/1100~1199/1189.Maximum-Number-of-Balloons.md" >}})|Easy||||61.7%|
|1221|Split a String in Balanced Strings|[Go]({{< relref "/ChapterFour/1200~1299/1221.Split-a-String-in-Balanced-Strings.md" >}})|Easy||||84.1%|
|1234|Replace the Substring for Balanced String|[Go]({{< relref "/ChapterFour/1200~1299/1234.Replace-the-Substring-for-Balanced-String.md" >}})|Medium||||34.3%|
|1455|Check If a Word Occurs As a Prefix of Any Word in a Sentence|[Go]({{< relref "/ChapterFour/1400~1499/1455.Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence.md" >}})|Easy||||64.5%|
|1455|Check If a Word Occurs As a Prefix of Any Word in a Sentence|[Go]({{< relref "/ChapterFour/1400~1499/1455.Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence.md" >}})|Easy||||64.4%|
|1573|Number of Ways to Split a String|[Go]({{< relref "/ChapterFour/1500~1599/1573.Number-of-Ways-to-Split-a-String.md" >}})|Medium||||31.0%|
|1653|Minimum Deletions to Make String Balanced|[Go]({{< relref "/ChapterFour/1600~1699/1653.Minimum-Deletions-to-Make-String-Balanced.md" >}})|Medium||||50.6%|
|1662|Check If Two String Arrays are Equivalent|[Go]({{< relref "/ChapterFour/1600~1699/1662.Check-If-Two-String-Arrays-are-Equivalent.md" >}})|Easy||||83.3%|
|1668|Maximum Repeating Substring|[Go]({{< relref "/ChapterFour/1600~1699/1668.Maximum-Repeating-Substring.md" >}})|Easy||||38.5%|
|1678|Goal Parser Interpretation|[Go]({{< relref "/ChapterFour/1600~1699/1678.Goal-Parser-Interpretation.md" >}})|Easy||||85.7%|
|1684|Count the Number of Consistent Strings|[Go]({{< relref "/ChapterFour/1600~1699/1684.Count-the-Number-of-Consistent-Strings.md" >}})|Easy||||83.3%|
|1694|Reformat Phone Number|[Go]({{< relref "/ChapterFour/1600~1699/1694.Reformat-Phone-Number.md" >}})|Easy||||66.2%|
|1684|Count the Number of Consistent Strings|[Go]({{< relref "/ChapterFour/1600~1699/1684.Count-the-Number-of-Consistent-Strings.md" >}})|Easy||||83.2%|
|1694|Reformat Phone Number|[Go]({{< relref "/ChapterFour/1600~1699/1694.Reformat-Phone-Number.md" >}})|Easy||||66.3%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -22,7 +22,7 @@ weight: 6
|0105|Construct Binary Tree from Preorder and Inorder Traversal|[Go]({{< relref "/ChapterFour/0100~0199/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal.md" >}})|Medium||||51.6%|
|0106|Construct Binary Tree from Inorder and Postorder Traversal|[Go]({{< relref "/ChapterFour/0100~0199/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal.md" >}})|Medium||||49.5%|
|0107|Binary Tree Level Order Traversal II|[Go]({{< relref "/ChapterFour/0100~0199/0107.Binary-Tree-Level-Order-Traversal-II.md" >}})|Easy| O(n)| O(1)||55.1%|
|0108|Convert Sorted Array to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}})|Easy| O(n)| O(1)||60.2%|
|0108|Convert Sorted Array to Binary Search Tree|[Go]({{< relref "/ChapterFour/0100~0199/0108.Convert-Sorted-Array-to-Binary-Search-Tree.md" >}})|Easy| O(n)| O(1)||60.3%|
|0110|Balanced Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0110.Balanced-Binary-Tree.md" >}})|Easy| O(n)| O(1)||44.7%|
|0111|Minimum Depth of Binary Tree|[Go]({{< relref "/ChapterFour/0100~0199/0111.Minimum-Depth-of-Binary-Tree.md" >}})|Easy| O(n)| O(1)||39.4%|
|0112|Path Sum|[Go]({{< relref "/ChapterFour/0100~0199/0112.Path-Sum.md" >}})|Easy| O(n)| O(1)||42.3%|
@ -36,7 +36,7 @@ weight: 6
|0199|Binary Tree Right Side View|[Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}})|Medium| O(n)| O(1)||56.3%|
|0222|Count Complete Tree Nodes|[Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}})|Medium| O(n)| O(1)||49.1%|
|0226|Invert Binary Tree|[Go]({{< relref "/ChapterFour/0200~0299/0226.Invert-Binary-Tree.md" >}})|Easy| O(n)| O(1)||66.9%|
|0230|Kth Smallest Element in a BST|[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})|Medium| O(n)| O(1)||62.4%|
|0230|Kth Smallest Element in a BST|[Go]({{< relref "/ChapterFour/0200~0299/0230.Kth-Smallest-Element-in-a-BST.md" >}})|Medium| O(n)| O(1)||62.5%|
|0235|Lowest Common Ancestor of a Binary Search Tree|[Go]({{< relref "/ChapterFour/0200~0299/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree.md" >}})|Easy| O(n)| O(1)||51.6%|
|0236|Lowest Common Ancestor of a Binary Tree|[Go]({{< relref "/ChapterFour/0200~0299/0236.Lowest-Common-Ancestor-of-a-Binary-Tree.md" >}})|Medium| O(n)| O(1)||48.5%|
|0257|Binary Tree Paths|[Go]({{< relref "/ChapterFour/0200~0299/0257.Binary-Tree-Paths.md" >}})|Easy| O(n)| O(1)||53.5%|
@ -52,8 +52,9 @@ weight: 6
|0637|Average of Levels in Binary Tree|[Go]({{< relref "/ChapterFour/0600~0699/0637.Average-of-Levels-in-Binary-Tree.md" >}})|Easy| O(n)| O(n)||64.7%|
|0653|Two Sum IV - Input is a BST|[Go]({{< relref "/ChapterFour/0600~0699/0653.Two-Sum-IV---Input-is-a-BST.md" >}})|Easy||||56.2%|
|0662|Maximum Width of Binary Tree|[Go]({{< relref "/ChapterFour/0600~0699/0662.Maximum-Width-of-Binary-Tree.md" >}})|Medium||||39.9%|
|0669|Trim a Binary Search Tree|[Go]({{< relref "/ChapterFour/0600~0699/0669.Trim-a-Binary-Search-Tree.md" >}})|Medium||||64.5%|
|0684|Redundant Connection|[Go]({{< relref "/ChapterFour/0600~0699/0684.Redundant-Connection.md" >}})|Medium||||58.9%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||32.9%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard||||33.0%|
|0834|Sum of Distances in Tree|[Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}})|Hard||||45.9%|
|0863|All Nodes Distance K in Binary Tree|[Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}})|Medium||||57.8%|
|0872|Leaf-Similar Trees|[Go]({{< relref "/ChapterFour/0800~0899/0872.Leaf-Similar-Trees.md" >}})|Easy||||64.6%|

View File

@ -40,7 +40,7 @@ weight: 3
|0019|Remove Nth Node From End of List|[Go]({{< relref "/ChapterFour/0001~0099/0019.Remove-Nth-Node-From-End-of-List.md" >}})|Medium| O(n)| O(1)||35.7%|
|0026|Remove Duplicates from Sorted Array|[Go]({{< relref "/ChapterFour/0001~0099/0026.Remove-Duplicates-from-Sorted-Array.md" >}})|Easy| O(n)| O(1)||46.5%|
|0027|Remove Element|[Go]({{< relref "/ChapterFour/0001~0099/0027.Remove-Element.md" >}})|Easy| O(n)| O(1)||49.2%|
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.1%|
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.2%|
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|0042|Trapping Rain Water|[Go]({{< relref "/ChapterFour/0001~0099/0042.Trapping-Rain-Water.md" >}})|Hard| O(n)| O(1)|❤️|51.0%|
|0061|Rotate List|[Go]({{< relref "/ChapterFour/0001~0099/0061.Rotate-List.md" >}})|Medium| O(n)| O(1)||31.7%|

View File

@ -25,7 +25,7 @@ weight: 16
|0399|Evaluate Division|[Go]({{< relref "/ChapterFour/0300~0399/0399.Evaluate-Division.md" >}})|Medium| O(n)| O(n)||54.2%|
|0547|Number of Provinces|[Go]({{< relref "/ChapterFour/0500~0599/0547.Number-of-Provinces.md" >}})|Medium| O(n^2)| O(n)||60.4%|
|0684|Redundant Connection|[Go]({{< relref "/ChapterFour/0600~0699/0684.Redundant-Connection.md" >}})|Medium| O(n)| O(n)||58.9%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard| O(n)| O(n)||32.9%|
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard| O(n)| O(n)||33.0%|
|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium| O(n)| O(n)|❤️|51.6%|
|0765|Couples Holding Hands|[Go]({{< relref "/ChapterFour/0700~0799/0765.Couples-Holding-Hands.md" >}})|Hard| O(n)| O(n)|❤️|55.4%|
|0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard| O(n^2)| O(n)|❤️|54.8%|
@ -38,12 +38,11 @@ weight: 16
|0959|Regions Cut By Slashes|[Go]({{< relref "/ChapterFour/0900~0999/0959.Regions-Cut-By-Slashes.md" >}})|Medium| O(n^2)| O(n^2)|❤️|67.1%|
|0990|Satisfiability of Equality Equations|[Go]({{< relref "/ChapterFour/0900~0999/0990.Satisfiability-of-Equality-Equations.md" >}})|Medium| O(n)| O(n)||46.7%|
|1202|Smallest String With Swaps|[Go]({{< relref "/ChapterFour/1200~1299/1202.Smallest-String-With-Swaps.md" >}})|Medium||||48.7%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.3%|
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.4%|
|1579|Remove Max Number of Edges to Keep Graph Fully Traversable|[Go]({{< relref "/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable.md" >}})|Hard||||46.2%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Bit_Manipulation/">⬅️上一页</a></p>