diff --git a/README.md b/README.md index 9814ae606..99c7c9d25 100755 --- a/README.md +++ b/README.md @@ -125,16 +125,16 @@ | | Easy | Medium | Hard | Total | |:--------:|:--------:|:--------:|:--------:|:--------:| -|Optimizing|38|43|15|96| -|Accepted|**260**|**329**|**101**|**690**| -|Total|463|924|374|1761| -|Perfection Rate|85.4%|86.9%|85.1%|86.1%| -|Completion Rate|56.2%|35.6%|27.0%|39.2%| +|Optimizing|37|44|15|96| +|Accepted|**272**|**330**|**101**|**703**| +|Total|462|925|374|1761| +|Perfection Rate|86.4%|86.7%|85.1%|86.3%| +|Completion Rate|58.9%|35.7%|27.0%|39.9%| |------------|----------------------------|----------------------------|----------------------------|----------------------------| ## 二. 目录 -以下已经收录了 594 道题的题解,还有 13 道题在尝试优化到 beats 100% +以下已经收录了 607 道题的题解,还有 13 道题在尝试优化到 beats 100% | No. | Title | Solution | Acceptance | Difficulty | Frequency | |:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:| @@ -152,7 +152,7 @@ |0012|Integer to Roman||56.1%|Medium|| |0013|Roman to Integer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0013.Roman-to-Integer)|56.5%|Easy|| |0014|Longest Common Prefix||36.1%|Easy|| -|0015|3Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0015.3Sum)|27.9%|Medium|| +|0015|3Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0015.3Sum)|28.0%|Medium|| |0016|3Sum Closest|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0016.3Sum-Closest)|46.3%|Medium|| |0017|Letter Combinations of a Phone Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0017.Letter-Combinations-of-a-Phone-Number)|49.0%|Medium|| |0018|4Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0018.4Sum)|34.8%|Medium|| @@ -175,11 +175,11 @@ |0035|Search Insert Position|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0035.Search-Insert-Position)|42.8%|Easy|| |0036|Valid Sudoku|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0036.Valid-Sudoku)|50.5%|Medium|| |0037|Sudoku Solver|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0037.Sudoku-Solver)|46.4%|Hard|| -|0038|Count and Say||46.0%|Easy|| +|0038|Count and Say||46.0%|Medium|| |0039|Combination Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0039.Combination-Sum)|59.1%|Medium|| |0040|Combination Sum II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0040.Combination-Sum-II)|50.0%|Medium|| |0041|First Missing Positive|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0041.First-Missing-Positive)|33.6%|Hard|| -|0042|Trapping Rain Water|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0042.Trapping-Rain-Water)|51.0%|Hard|| +|0042|Trapping Rain Water|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0042.Trapping-Rain-Water)|51.1%|Hard|| |0043|Multiply Strings||34.9%|Medium|| |0044|Wildcard Matching||25.4%|Hard|| |0045|Jump Game II||31.4%|Hard|| @@ -205,13 +205,13 @@ |0065|Valid Number||15.8%|Hard|| |0066|Plus One|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0066.Plus-One)|42.3%|Easy|| |0067|Add Binary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0067.Add-Binary)|46.8%|Easy|| -|0068|Text Justification||29.5%|Hard|| +|0068|Text Justification||29.6%|Hard|| |0069|Sqrt(x)|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0069.Sqrt(x))|35.0%|Easy|| |0070|Climbing Stairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0070.Climbing-Stairs)|48.6%|Easy|| |0071|Simplify Path|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0071.Simplify-Path)|34.6%|Medium|| |0072|Edit Distance||46.6%|Hard|| |0073|Set Matrix Zeroes||44.3%|Medium|| -|0074|Search a 2D Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0074.Search-a-2D-Matrix)|37.6%|Medium|| +|0074|Search a 2D Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0074.Search-a-2D-Matrix)|37.7%|Medium|| |0075|Sort Colors|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0075.Sort-Colors)|49.3%|Medium|| |0076|Minimum Window Substring|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0076.Minimum-Window-Substring)|35.9%|Hard|| |0077|Combinations|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0077.Combinations)|57.3%|Medium|| @@ -230,10 +230,10 @@ |0090|Subsets II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0090.Subsets-II)|48.7%|Medium|| |0091|Decode Ways|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0091.Decode-Ways)|26.5%|Medium|| |0092|Reverse Linked List II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0092.Reverse-Linked-List-II)|40.5%|Medium|| -|0093|Restore IP Addresses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0093.Restore-IP-Addresses)|37.4%|Medium|| +|0093|Restore IP Addresses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0093.Restore-IP-Addresses)|37.5%|Medium|| |0094|Binary Tree Inorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0094.Binary-Tree-Inorder-Traversal)|65.7%|Medium|| |0095|Unique Binary Search Trees II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0095.Unique-Binary-Search-Trees-II)|42.4%|Medium|| -|0096|Unique Binary Search Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0096.Unique-Binary-Search-Trees)|54.3%|Medium|| +|0096|Unique Binary Search Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0096.Unique-Binary-Search-Trees)|54.4%|Medium|| |0097|Interleaving String||32.5%|Hard|| |0098|Validate Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0098.Validate-Binary-Search-Tree)|28.7%|Medium|| |0099|Recover Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0099.Recover-Binary-Search-Tree)|42.4%|Hard|| @@ -248,8 +248,8 @@ |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|| -|0112|Path Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0112.Path-Sum)|42.3%|Easy|| +|0111|Minimum Depth of Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0111.Minimum-Depth-of-Binary-Tree)|39.5%|Easy|| +|0112|Path Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0112.Path-Sum)|42.4%|Easy|| |0113|Path Sum II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0113.Path-Sum-II)|49.0%|Medium|| |0114|Flatten Binary Tree to Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0114.Flatten-Binary-Tree-to-Linked-List)|51.8%|Medium|| |0115|Distinct Subsequences||39.6%|Hard|| @@ -272,7 +272,7 @@ |0132|Palindrome Partitioning II||31.2%|Hard|| |0133|Clone Graph||39.0%|Medium|| |0134|Gas Station||41.2%|Medium|| -|0135|Candy||32.9%|Hard|| +|0135|Candy||33.0%|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.7%|Medium|| @@ -282,7 +282,7 @@ |0142|Linked List Cycle II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0142.Linked-List-Cycle-II)|39.6%|Medium|| |0143|Reorder List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0143.Reorder-List)|40.5%|Medium|| |0144|Binary Tree Preorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0144.Binary-Tree-Preorder-Traversal)|57.4%|Medium|| -|0145|Binary Tree Postorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0145.Binary-Tree-Postorder-Traversal)|57.4%|Medium|| +|0145|Binary Tree Postorder Traversal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0145.Binary-Tree-Postorder-Traversal)|57.5%|Medium|| |0146|LRU Cache|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0146.LRU-Cache)|35.6%|Medium|| |0147|Insertion Sort List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0147.Insertion-Sort-List)|44.3%|Medium|| |0148|Sort List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0148.Sort-List)|46.1%|Medium|| @@ -297,13 +297,13 @@ |0157|Read N Characters Given Read4||37.2%|Easy|| |0158|Read N Characters Given Read4 II - Call multiple times||36.7%|Hard|| |0159|Longest Substring with At Most Two Distinct Characters||50.4%|Medium|| -|0160|Intersection of Two Linked Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0160.Intersection-of-Two-Linked-Lists)|43.0%|Easy|| +|0160|Intersection of Two Linked Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0160.Intersection-of-Two-Linked-Lists)|43.1%|Easy|| |0161|One Edit Distance||33.0%|Medium|| |0162|Find Peak Element|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0162.Find-Peak-Element)|43.9%|Medium|| |0163|Missing Ranges||26.8%|Easy|| -|0164|Maximum Gap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0164.Maximum-Gap)|36.7%|Hard|| +|0164|Maximum Gap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0164.Maximum-Gap)|36.8%|Hard|| |0165|Compare Version Numbers||30.3%|Medium|| -|0166|Fraction to Recurring Decimal||22.2%|Medium|| +|0166|Fraction to Recurring Decimal||22.3%|Medium|| |0167|Two Sum II - Input array is sorted|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0167.Two-Sum-II---Input-array-is-sorted)|55.6%|Easy|| |0168|Excel Sheet Column Title|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0168.Excel-Sheet-Column-Title)|31.7%|Easy|| |0169|Majority Element|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0169.Majority-Element)|60.0%|Easy|| @@ -318,9 +318,9 @@ |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.1%|Medium|| -|0181|Employees Earning More Than Their Managers||60.1%|Easy|| +|0181|Employees Earning More Than Their Managers||60.2%|Easy|| |0182|Duplicate Emails||64.4%|Easy|| -|0183|Customers Who Never Order||56.6%|Easy|| +|0183|Customers Who Never Order||56.7%|Easy|| |0184|Department Highest Salary||39.9%|Medium|| |0185|Department Top Three Salaries||38.7%|Hard|| |0186|Reverse Words in a String II||45.4%|Medium|| @@ -359,7 +359,7 @@ |0219|Contains Duplicate II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0219.Contains-Duplicate-II)|38.6%|Easy|| |0220|Contains Duplicate III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0220.Contains-Duplicate-III)|21.3%|Medium|| |0221|Maximal Square||39.1%|Medium|| -|0222|Count Complete Tree Nodes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0222.Count-Complete-Tree-Nodes)|49.1%|Medium|| +|0222|Count Complete Tree Nodes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0222.Count-Complete-Tree-Nodes)|49.2%|Medium|| |0223|Rectangle Area|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0223.Rectangle-Area)|38.2%|Medium|| |0224|Basic Calculator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0224.Basic-Calculator)|38.1%|Hard|| |0225|Implement Stack using Queues|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0225.Implement-Stack-using-Queues)|47.3%|Easy|| @@ -372,8 +372,8 @@ |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|| |0234|Palindrome Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0234.Palindrome-Linked-List)|40.4%|Easy|| -|0235|Lowest Common Ancestor of a Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree)|51.6%|Easy|| -|0236|Lowest Common Ancestor of a Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0236.Lowest-Common-Ancestor-of-a-Binary-Tree)|48.5%|Medium|| +|0235|Lowest Common Ancestor of a Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0235.Lowest-Common-Ancestor-of-a-Binary-Search-Tree)|51.7%|Easy|| +|0236|Lowest Common Ancestor of a Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0236.Lowest-Common-Ancestor-of-a-Binary-Tree)|48.6%|Medium|| |0237|Delete Node in a Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0237.Delete-Node-in-a-Linked-List)|66.7%|Easy|| |0238|Product of Array Except Self||61.4%|Medium|| |0239|Sliding Window Maximum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0239.Sliding-Window-Maximum)|44.6%|Hard|| @@ -384,15 +384,15 @@ |0244|Shortest Word Distance II||53.9%|Medium|| |0245|Shortest Word Distance III||55.9%|Medium|| |0246|Strobogrammatic Number||45.8%|Easy|| -|0247|Strobogrammatic Number II||48.4%|Medium|| +|0247|Strobogrammatic Number II||48.5%|Medium|| |0248|Strobogrammatic Number III||40.2%|Hard|| -|0249|Group Shifted Strings||57.9%|Medium|| +|0249|Group Shifted Strings||58.0%|Medium|| |0250|Count Univalue Subtrees||53.3%|Medium|| |0251|Flatten 2D Vector||46.3%|Medium|| |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|| +|0255|Verify Preorder Sequence in Binary Search Tree||46.2%|Medium|| |0256|Paint House||53.5%|Medium|| |0257|Binary Tree Paths|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0257.Binary-Tree-Paths)|53.5%|Easy|| |0258|Add Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0258.Add-Digits)|58.4%|Easy|| @@ -410,7 +410,7 @@ |0270|Closest Binary Search Tree Value||49.8%|Easy|| |0271|Encode and Decode Strings||32.7%|Medium|| |0272|Closest Binary Search Tree Value II||52.2%|Hard|| -|0273|Integer to English Words||28.0%|Hard|| +|0273|Integer to English Words||28.1%|Hard|| |0274|H-Index|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0274.H-Index)|36.3%|Medium|| |0275|H-Index II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0275.H-Index-II)|36.3%|Medium|| |0276|Paint Fence||39.0%|Easy|| @@ -421,8 +421,8 @@ |0281|Zigzag Iterator||59.4%|Medium|| |0282|Expression Add Operators||36.7%|Hard|| |0283|Move Zeroes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0283.Move-Zeroes)|58.5%|Easy|| -|0284|Peeking Iterator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0284.Peeking-Iterator)|50.4%|Medium|| -|0285|Inorder Successor in BST||42.7%|Medium|| +|0284|Peeking Iterator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0284.Peeking-Iterator)|50.5%|Medium|| +|0285|Inorder Successor in BST||42.8%|Medium|| |0286|Walls and Gates||56.3%|Medium|| |0287|Find the Duplicate Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0287.Find-the-Duplicate-Number)|57.4%|Medium|| |0288|Unique Word Abbreviation||23.0%|Medium|| @@ -461,8 +461,8 @@ |0321|Create Maximum Number||27.5%|Hard|| |0322|Coin Change|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0322.Coin-Change)|37.1%|Medium|| |0323|Number of Connected Components in an Undirected Graph||57.7%|Medium|| -|0324|Wiggle Sort II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0324.Wiggle-Sort-II)|30.6%|Medium|| -|0325|Maximum Size Subarray Sum Equals k||47.3%|Medium|| +|0324|Wiggle Sort II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0324.Wiggle-Sort-II)|30.7%|Medium|| +|0325|Maximum Size Subarray Sum Equals k||47.4%|Medium|| |0326|Power of Three|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0326.Power-of-Three)|42.1%|Easy|| |0327|Count of Range Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0327.Count-of-Range-Sum)|36.0%|Hard|| |0328|Odd Even Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0328.Odd-Even-Linked-List)|57.0%|Medium|| @@ -473,7 +473,7 @@ |0333|Largest BST Subtree||37.7%|Medium|| |0334|Increasing Triplet Subsequence||40.7%|Medium|| |0335|Self Crossing||28.6%|Hard|| -|0336|Palindrome Pairs||34.5%|Hard|| +|0336|Palindrome Pairs||34.6%|Hard|| |0337|House Robber III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0337.House-Robber-III)|51.8%|Medium|| |0338|Counting Bits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0338.Counting-Bits)|70.3%|Medium|| |0339|Nested List Weight Sum||76.3%|Medium|| @@ -484,7 +484,7 @@ |0344|Reverse String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0344.Reverse-String)|70.2%|Easy|| |0345|Reverse Vowels of a String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0345.Reverse-Vowels-of-a-String)|45.0%|Easy|| |0346|Moving Average from Data Stream||73.1%|Easy|| -|0347|Top K Frequent Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0347.Top-K-Frequent-Elements)|62.3%|Medium|| +|0347|Top K Frequent Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0347.Top-K-Frequent-Elements)|62.4%|Medium|| |0348|Design Tic-Tac-Toe||55.5%|Medium|| |0349|Intersection of Two Arrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0349.Intersection-of-Two-Arrays)|64.7%|Easy|| |0350|Intersection of Two Arrays II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0350.Intersection-of-Two-Arrays-II)|52.0%|Easy|| @@ -496,7 +496,7 @@ |0356|Line Reflection||32.8%|Medium|| |0357|Count Numbers with Unique Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0357.Count-Numbers-with-Unique-Digits)|48.8%|Medium|| |0358|Rearrange String k Distance Apart||35.6%|Hard|| -|0359|Logger Rate Limiter||72.1%|Easy|| +|0359|Logger Rate Limiter||72.2%|Easy|| |0360|Sort Transformed Array||49.6%|Medium|| |0361|Bomb Enemy||46.6%|Medium|| |0362|Design Hit Counter||65.2%|Medium|| @@ -536,11 +536,11 @@ |0396|Rotate Function||36.7%|Medium|| |0397|Integer Replacement|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0397.Integer-Replacement)|33.5%|Medium|| |0398|Random Pick Index||57.8%|Medium|| -|0399|Evaluate Division|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0399.Evaluate-Division)|54.2%|Medium|| +|0399|Evaluate Division|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0399.Evaluate-Division)|54.3%|Medium|| |0400|Nth Digit||32.4%|Medium|| |0401|Binary Watch|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0401.Binary-Watch)|48.4%|Easy|| |0402|Remove K Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0402.Remove-K-Digits)|28.6%|Medium|| -|0403|Frog Jump||41.4%|Hard|| +|0403|Frog Jump||41.3%|Hard|| |0404|Sum of Left Leaves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0404.Sum-of-Left-Leaves)|52.2%|Easy|| |0405|Convert a Number to Hexadecimal|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0405.Convert-a-Number-to-Hexadecimal)|44.4%|Easy|| |0406|Queue Reconstruction by Height||68.3%|Medium|| @@ -558,7 +558,7 @@ |0418|Sentence Screen Fitting||33.1%|Medium|| |0419|Battleships in a Board||71.0%|Medium|| |0420|Strong Password Checker||14.0%|Hard|| -|0421|Maximum XOR of Two Numbers in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0421.Maximum-XOR-of-Two-Numbers-in-an-Array)|54.1%|Medium|| +|0421|Maximum XOR of Two Numbers in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0421.Maximum-XOR-of-Two-Numbers-in-an-Array)|54.0%|Medium|| |0422|Valid Word Square||38.1%|Easy|| |0423|Reconstruct Original Digits from English||47.5%|Medium|| |0424|Longest Repeating Character Replacement|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0424.Longest-Repeating-Character-Replacement)|48.2%|Medium|| @@ -578,7 +578,7 @@ |0438|Find All Anagrams in a String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0438.Find-All-Anagrams-in-a-String)|44.9%|Medium|| |0439|Ternary Expression Parser||56.7%|Medium|| |0440|K-th Smallest in Lexicographical Order||29.8%|Hard|| -|0441|Arranging Coins|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0441.Arranging-Coins)|42.3%|Easy|| +|0441|Arranging Coins|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0441.Arranging-Coins)|42.4%|Easy|| |0442|Find All Duplicates in an Array||68.9%|Medium|| |0443|String Compression||43.5%|Medium|| |0444|Sequence Reconstruction||23.5%|Medium|| @@ -597,7 +597,7 @@ |0457|Circular Array Loop|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0457.Circular-Array-Loop)|30.0%|Medium|| |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|| +|0460|LFU Cache|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0460.LFU-Cache)|36.0%|Hard|| |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|| @@ -631,9 +631,9 @@ |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|| |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|| +|0494|Target Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0494.Target-Sum)|45.7%|Medium|| |0495|Teemo Attacking||56.1%|Medium|| -|0496|Next Greater Element I|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0496.Next-Greater-Element-I)|65.4%|Easy|| +|0496|Next Greater Element I|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0496.Next-Greater-Element-I)|65.5%|Easy|| |0497|Random Point in Non-overlapping Rectangles|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0497.Random-Point-in-Non-overlapping-Rectangles)|39.1%|Medium|| |0498|Diagonal Traverse|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0498.Diagonal-Traverse)|50.2%|Medium|| |0499|The Maze III||42.4%|Hard|| @@ -649,7 +649,7 @@ |0509|Fibonacci Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0509.Fibonacci-Number)|67.4%|Easy|| |0510|Inorder Successor in BST II||60.0%|Medium|| |0511|Game Play Analysis I||81.3%|Easy|| -|0512|Game Play Analysis II||55.9%|Easy|| +|0512|Game Play Analysis II||56.0%|Easy|| |0513|Find Bottom Left Tree Value|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0513.Find-Bottom-Left-Tree-Value)|62.5%|Medium|| |0514|Freedom Trail||44.9%|Hard|| |0515|Find Largest Value in Each Tree Row|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0515.Find-Largest-Value-in-Each-Tree-Row)|62.2%|Medium|| @@ -679,15 +679,15 @@ |0539|Minimum Time Difference||52.3%|Medium|| |0540|Single Element in a Sorted Array||57.9%|Medium|| |0541|Reverse String II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0541.Reverse-String-II)|49.1%|Easy|| -|0542|01 Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0542.01-Matrix)|40.8%|Medium|| +|0542|01 Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0542.01-Matrix)|40.9%|Medium|| |0543|Diameter of Binary Tree||49.1%|Easy|| |0544|Output Contest Matches||75.8%|Medium|| -|0545|Boundary of Binary Tree||39.6%|Medium|| +|0545|Boundary of Binary Tree||39.7%|Medium|| |0546|Remove Boxes||44.2%|Hard|| |0547|Number of Provinces|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0547.Number-of-Provinces)|60.4%|Medium|| |0548|Split Array with Equal Sum||47.9%|Medium|| |0549|Binary Tree Longest Consecutive Sequence II||47.2%|Medium|| -|0550|Game Play Analysis IV||45.6%|Medium|| +|0550|Game Play Analysis IV||45.7%|Medium|| |0551|Student Attendance Record I||46.0%|Easy|| |0552|Student Attendance Record II||37.3%|Hard|| |0553|Optimal Division||57.4%|Medium|| @@ -706,18 +706,18 @@ |0566|Reshape the Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0566.Reshape-the-Matrix)|61.0%|Easy|| |0567|Permutation in String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0567.Permutation-in-String)|44.6%|Medium|| |0568|Maximum Vacation Days||41.5%|Hard|| -|0569|Median Employee Salary||61.4%|Hard|| +|0569|Median Employee Salary||61.5%|Hard|| |0570|Managers with at Least 5 Direct Reports||66.8%|Medium|| |0571|Find Median Given Frequency of Numbers||45.6%|Hard|| |0572|Subtree of Another Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0572.Subtree-of-Another-Tree)|44.5%|Easy|| -|0573|Squirrel Simulation||54.3%|Medium|| +|0573|Squirrel Simulation||54.4%|Medium|| |0574|Winning Candidate||51.8%|Medium|| |0575|Distribute Candies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0575.Distribute-Candies)|62.1%|Easy|| |0576|Out of Boundary Paths||35.9%|Medium|| |0577|Employee Bonus||71.3%|Easy|| |0578|Get Highest Answer Rate Question||41.6%|Medium|| |0579|Find Cumulative Salary of an Employee||38.2%|Hard|| -|0580|Count Student Number in Departments||51.5%|Medium|| +|0580|Count Student Number in Departments||51.6%|Medium|| |0581|Shortest Unsorted Continuous Subarray||31.7%|Medium|| |0582|Kill Process||62.6%|Medium|| |0583|Delete Operation for Two Strings||49.9%|Medium|| @@ -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.7%|Easy|| +|0596|Classes More Than 5 Students||38.8%|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|| @@ -768,8 +768,8 @@ |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|| |0630|Course Schedule III||33.8%|Hard|| -|0631|Design Excel Sum Formula||32.1%|Hard|| -|0632|Smallest Range Covering Elements from K Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0632.Smallest-Range-Covering-Elements-from-K-Lists)|54.1%|Hard|| +|0631|Design Excel Sum Formula||32.2%|Hard|| +|0632|Smallest Range Covering Elements from K Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0632.Smallest-Range-Covering-Elements-from-K-Lists)|54.2%|Hard|| |0633|Sum of Square Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0633.Sum-of-Square-Numbers)|32.5%|Medium|| |0634|Find the Derangement of An Array||40.5%|Medium|| |0635|Design Log Storage System||59.7%|Medium|| @@ -785,7 +785,7 @@ |0645|Set Mismatch|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0645.Set-Mismatch)|42.5%|Easy|| |0646|Maximum Length of Pair Chain||52.9%|Medium|| |0647|Palindromic Substrings||61.8%|Medium|| -|0648|Replace Words|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0648.Replace-Words)|58.4%|Medium|| +|0648|Replace Words|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0648.Replace-Words)|58.5%|Medium|| |0649|Dota2 Senate||39.5%|Medium|| |0650|2 Keys Keyboard||50.0%|Medium|| |0651|4 Keys Keyboard||53.0%|Medium|| @@ -796,7 +796,7 @@ |0656|Coin Path||29.6%|Hard|| |0657|Robot Return to Origin||73.7%|Easy|| |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|| +|0659|Split Array into Consecutive Subsequences||44.4%|Medium|| |0660|Remove 9||54.2%|Hard|| |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|| @@ -819,14 +819,14 @@ |0679|24 Game||47.2%|Hard|| |0680|Valid Palindrome II||37.1%|Easy|| |0681|Next Closest Time||45.9%|Medium|| -|0682|Baseball Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0682.Baseball-Game)|66.7%|Easy|| +|0682|Baseball Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0682.Baseball-Game)|66.8%|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)|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.1%|Hard|| +|0689|Maximum Sum of 3 Non-Overlapping Subarrays||47.2%|Hard|| |0690|Employee Importance||58.7%|Easy|| |0691|Stickers to Spell Word||44.5%|Hard|| |0692|Top K Frequent Words||53.0%|Medium|| @@ -857,8 +857,8 @@ |0717|1-bit and 2-bit Characters|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0717.1-bit-and-2-bit-Characters)|47.3%|Easy|| |0718|Maximum Length of Repeated Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0718.Maximum-Length-of-Repeated-Subarray)|50.3%|Medium|| |0719|Find K-th Smallest Pair Distance|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0719.Find-K-th-Smallest-Pair-Distance)|32.5%|Hard|| -|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|| +|0720|Longest Word in Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0720.Longest-Word-in-Dictionary)|49.2%|Easy|| +|0721|Accounts Merge|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0721.Accounts-Merge)|51.7%|Medium|| |0722|Remove Comments||36.0%|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|| @@ -872,7 +872,7 @@ |0732|My Calendar III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0732.My-Calendar-III)|61.7%|Hard|| |0733|Flood Fill|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0733.Flood-Fill)|55.9%|Easy|| |0734|Sentence Similarity||42.3%|Easy|| -|0735|Asteroid Collision|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0735.Asteroid-Collision)|43.3%|Medium|| +|0735|Asteroid Collision|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0735.Asteroid-Collision)|43.2%|Medium|| |0736|Parse Lisp Expression||49.8%|Hard|| |0737|Sentence Similarity II||46.5%|Medium|| |0738|Monotone Increasing Digits||45.6%|Medium|| @@ -907,23 +907,23 @@ |0767|Reorganize String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0767.Reorganize-String)|50.0%|Medium|| |0768|Max Chunks To Make Sorted II||49.7%|Hard|| |0769|Max Chunks To Make Sorted||55.5%|Medium|| -|0770|Basic Calculator IV||54.1%|Hard|| +|0770|Basic Calculator IV||54.0%|Hard|| |0771|Jewels and Stones|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0771.Jewels-and-Stones)|86.9%|Easy|| |0772|Basic Calculator III||43.5%|Hard|| |0773|Sliding Puzzle||60.8%|Hard|| -|0774|Minimize Max Distance to Gas Station||48.2%|Hard|| +|0774|Minimize Max Distance to Gas Station||48.3%|Hard|| |0775|Global and Local Inversions||42.6%|Medium|| |0776|Split BST||56.6%|Medium|| |0777|Swap Adjacent in LR String||35.6%|Medium|| |0778|Swim in Rising Water|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0778.Swim-in-Rising-Water)|54.8%|Hard|| -|0779|K-th Symbol in Grammar||38.5%|Medium|| +|0779|K-th Symbol in Grammar||38.6%|Medium|| |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.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|| +|0785|Is Graph Bipartite?|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0785.Is-Graph-Bipartite?)|48.6%|Medium|| +|0786|K-th Smallest Prime Fraction|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0786.K-th-Smallest-Prime-Fraction)|42.4%|Hard|| |0787|Cheapest Flights Within K Stops||39.5%|Medium|| |0788|Rotated Digits||57.1%|Easy|| |0789|Escape The Ghosts||58.3%|Medium|| @@ -937,7 +937,7 @@ |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|| -|0800|Similar RGB Color||62.2%|Easy|| +|0800|Similar RGB Color||62.3%|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|| |0803|Bricks Falling When Hit|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0803.Bricks-Falling-When-Hit)|31.4%|Hard|| @@ -976,7 +976,7 @@ |0836|Rectangle Overlap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0836.Rectangle-Overlap)|44.7%|Easy|| |0837|New 21 Game||35.3%|Medium|| |0838|Push Dominoes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0838.Push-Dominoes)|49.8%|Medium|| -|0839|Similar String Groups|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0839.Similar-String-Groups)|40.5%|Hard|| +|0839|Similar String Groups|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0839.Similar-String-Groups)|40.6%|Hard|| |0840|Magic Squares In Grid||37.8%|Medium|| |0841|Keys and Rooms|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0841.Keys-and-Rooms)|65.4%|Medium|| |0842|Split Array into Fibonacci Sequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0842.Split-Array-into-Fibonacci-Sequence)|36.8%|Medium|| @@ -990,7 +990,7 @@ |0850|Rectangle Area II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0850.Rectangle-Area-II)|48.3%|Hard|| |0851|Loud and Rich|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0851.Loud-and-Rich)|52.6%|Medium|| |0852|Peak Index in a Mountain Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0852.Peak-Index-in-a-Mountain-Array)|71.7%|Easy|| -|0853|Car Fleet|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0853.Car-Fleet)|43.7%|Medium|| +|0853|Car Fleet|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0853.Car-Fleet)|43.8%|Medium|| |0854|K-Similar Strings||38.7%|Hard|| |0855|Exam Room||43.4%|Medium|| |0856|Score of Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0856.Score-of-Parentheses)|62.4%|Medium|| @@ -1015,7 +1015,7 @@ |0875|Koko Eating Bananas|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0875.Koko-Eating-Bananas)|53.5%|Medium|| |0876|Middle of the Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0876.Middle-of-the-Linked-List)|69.1%|Easy|| |0877|Stone Game||66.5%|Medium|| -|0878|Nth Magical Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0878.Nth-Magical-Number)|28.8%|Hard|| +|0878|Nth Magical Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0878.Nth-Magical-Number)|28.9%|Hard|| |0879|Profitable Schemes||40.0%|Hard|| |0880|Decoded String at Index|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0880.Decoded-String-at-Index)|28.3%|Medium|| |0881|Boats to Save People|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0881.Boats-to-Save-People)|48.8%|Medium|| @@ -1048,10 +1048,10 @@ |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|| +|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.2%|Easy|| |0915|Partition Array into Disjoint Intervals||46.1%|Medium|| |0916|Word Subsets||48.2%|Medium|| |0917|Reverse Only Letters||58.7%|Easy|| @@ -1063,7 +1063,7 @@ |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.9%|Hard|| |0925|Long Pressed Name|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0925.Long-Pressed-Name)|38.1%|Easy|| -|0926|Flip String to Monotone Increasing||53.1%|Medium|| +|0926|Flip String to Monotone Increasing||53.2%|Medium|| |0927|Three Equal Parts|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0927.Three-Equal-Parts)|34.6%|Hard|| |0928|Minimize Malware Spread II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0928.Minimize-Malware-Spread-II)|41.2%|Hard|| |0929|Unique Email Addresses||67.1%|Easy|| @@ -1094,10 +1094,10 @@ |0954|Array of Doubled Pairs||35.2%|Medium|| |0955|Delete Columns to Make Sorted II||33.8%|Medium|| |0956|Tallest Billboard||39.9%|Hard|| -|0957|Prison Cells After N Days||40.1%|Medium|| +|0957|Prison Cells After N Days||40.2%|Medium|| |0958|Check Completeness of a Binary Tree||52.5%|Medium|| |0959|Regions Cut By Slashes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0959.Regions-Cut-By-Slashes)|67.1%|Medium|| -|0960|Delete Columns to Make Sorted III||54.8%|Hard|| +|0960|Delete Columns to Make Sorted III||54.9%|Hard|| |0961|N-Repeated Element in Size 2N Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0961.N-Repeated-Element-in-Size-2N-Array)|74.4%|Easy|| |0962|Maximum Width Ramp||46.5%|Medium|| |0963|Minimum Area Rectangle II||51.8%|Medium|| @@ -1124,7 +1124,7 @@ |0984|String Without AAA or BBB|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0984.String-Without-AAA-or-BBB)|38.6%|Medium|| |0985|Sum of Even Numbers After Queries|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0985.Sum-of-Even-Numbers-After-Queries)|60.7%|Easy|| |0986|Interval List Intersections|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0986.Interval-List-Intersections)|68.3%|Medium|| -|0987|Vertical Order Traversal of a Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0987.Vertical-Order-Traversal-of-a-Binary-Tree)|38.7%|Hard|| +|0987|Vertical Order Traversal of a Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0987.Vertical-Order-Traversal-of-a-Binary-Tree)|38.8%|Hard|| |0988|Smallest String Starting From Leaf||46.7%|Medium|| |0989|Add to Array-Form of Integer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0989.Add-to-Array-Form-of-Integer)|44.8%|Easy|| |0990|Satisfiability of Equality Equations|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0990.Satisfiability-of-Equality-Equations)|46.7%|Medium|| @@ -1169,7 +1169,7 @@ |1029|Two City Scheduling||57.9%|Medium|| |1030|Matrix Cells in Distance Order|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1030.Matrix-Cells-in-Distance-Order)|66.9%|Easy|| |1031|Maximum Sum of Two Non-Overlapping Subarrays||58.9%|Medium|| -|1032|Stream of Characters||48.7%|Hard|| +|1032|Stream of Characters||48.6%|Hard|| |1033|Moving Stones Until Consecutive||43.1%|Easy|| |1034|Coloring A Border||45.6%|Medium|| |1035|Uncrossed Lines||56.0%|Medium|| @@ -1180,11 +1180,11 @@ |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|| |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|| +|1043|Partition Array for Maximum Sum||66.9%|Medium|| +|1044|Longest Duplicate Substring||31.4%|Hard|| |1045|Customers Who Bought All Products||68.4%|Medium|| |1046|Last Stone Weight||62.4%|Easy|| -|1047|Remove All Adjacent Duplicates In String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1047.Remove-All-Adjacent-Duplicates-In-String)|70.6%|Easy|| +|1047|Remove All Adjacent Duplicates In String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1047.Remove-All-Adjacent-Duplicates-In-String)|70.7%|Easy|| |1048|Longest String Chain||55.4%|Medium|| |1049|Last Stone Weight II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1049.Last-Stone-Weight-II)|45.2%|Medium|| |1050|Actors and Directors Who Cooperated At Least Three Times||72.3%|Easy|| @@ -1198,17 +1198,17 @@ |1058|Minimize Rounding Error to Meet Target||43.0%|Medium|| |1059|All Paths from Source Lead to Destination||43.2%|Medium|| |1060|Missing Element in Sorted Array||54.7%|Medium|| -|1061|Lexicographically Smallest Equivalent String||66.6%|Medium|| +|1061|Lexicographically Smallest Equivalent String||66.7%|Medium|| |1062|Longest Repeating Substring||58.3%|Medium|| |1063|Number of Valid Subarrays||72.1%|Hard|| |1064|Fixed Point||65.2%|Easy|| -|1065|Index Pairs of a String||60.9%|Easy|| +|1065|Index Pairs of a String||61.0%|Easy|| |1066|Campus Bikes II||54.1%|Medium|| |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.2%|Easy|| +|1071|Greatest Common Divisor of Strings||51.3%|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|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1091.Shortest-Path-in-Binary-Matrix)|39.9%|Medium|| +|1091|Shortest Path in Binary Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1091.Shortest-Path-in-Binary-Matrix)|40.0%|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|| @@ -1249,9 +1249,9 @@ |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.7%|Medium|| -|1112|Highest Grade For Each Student||71.9%|Medium|| +|1112|Highest Grade For Each Student||72.0%|Medium|| |1113|Reported Posts||65.7%|Easy|| -|1114|Print in Order||67.0%|Easy|| +|1114|Print in Order||67.1%|Easy|| |1115|Print FooBar Alternately||59.0%|Medium|| |1116|Print Zero Even Odd||57.7%|Medium|| |1117|Building H2O||53.1%|Medium|| @@ -1288,13 +1288,13 @@ |1148|Article Views I||77.1%|Easy|| |1149|Article Views II||48.2%|Medium|| |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|| +|1151|Minimum Swaps to Group All 1's Together||58.4%|Medium|| |1152|Analyze User Website Visit Pattern||43.3%|Medium|| |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.2%|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.6%|Hard|| +|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|| |1158|Market Analysis I||63.9%|Medium|| |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|| @@ -1316,7 +1316,7 @@ |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||82.0%|Easy|| +|1179|Reformat Department Table||81.9%|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|| @@ -1343,7 +1343,7 @@ |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.7%|Medium|| |1205|Monthly Transactions II||45.8%|Medium|| -|1206|Design Skiplist||59.1%|Hard|| +|1206|Design Skiplist||59.0%|Hard|| |1207|Unique Number of Occurrences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1207.Unique-Number-of-Occurrences)|71.7%|Easy|| |1208|Get Equal Substrings Within Budget|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1208.Get-Equal-Substrings-Within-Budget)|43.9%|Medium|| |1209|Remove All Adjacent Duplicates in String II||57.6%|Medium|| @@ -1356,15 +1356,15 @@ |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.6%|Medium|| -|1219|Path with Maximum Gold||65.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.6%|Hard|| -|1225|Report Contiguous Dates||62.6%|Hard|| -|1226|The Dining Philosophers||59.8%|Medium|| -|1227|Airplane Seat Assignment Probability||62.0%|Medium|| +|1225|Report Contiguous Dates||62.7%|Hard|| +|1226|The Dining Philosophers||59.7%|Medium|| +|1227|Airplane Seat Assignment Probability||62.1%|Medium|| |1228|Missing Number In Arithmetic Progression||51.4%|Easy|| |1229|Meeting Scheduler||54.4%|Medium|| |1230|Toss Strange Coins||50.0%|Medium|| @@ -1395,18 +1395,18 @@ |1255|Maximum Score Words Formed by Letters||69.9%|Hard|| |1256|Encode Number||67.7%|Medium|| |1257|Smallest Common Region||60.8%|Medium|| -|1258|Synonymous Sentences||63.7%|Medium|| +|1258|Synonymous Sentences||63.6%|Medium|| |1259|Handshakes That Don't Cross||54.2%|Hard|| |1260|Shift 2D Grid|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1260.Shift-2D-Grid)|61.8%|Easy|| |1261|Find Elements in a Contaminated Binary Tree||74.6%|Medium|| -|1262|Greatest Sum Divisible by Three||49.5%|Medium|| +|1262|Greatest Sum Divisible by Three||49.6%|Medium|| |1263|Minimum Moves to Move a Box to Their Target Location||43.2%|Hard|| |1264|Page Recommendations||69.1%|Medium|| |1265|Print Immutable Linked List in Reverse||94.4%|Medium|| |1266|Minimum Time Visiting All Points|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1266.Minimum-Time-Visiting-All-Points)|79.5%|Easy|| |1267|Count Servers that Communicate||57.7%|Medium|| |1268|Search Suggestions System||64.6%|Medium|| -|1269|Number of Ways to Stay in the Same Place After Some Steps||43.3%|Hard|| +|1269|Number of Ways to Stay in the Same Place After Some Steps||43.2%|Hard|| |1270|All People Report to the Given Manager||88.3%|Medium|| |1271|Hexspeak||55.4%|Easy|| |1272|Remove Interval||57.9%|Medium|| @@ -1420,7 +1420,7 @@ |1280|Students and Examinations||74.6%|Easy|| |1281|Subtract the Product and Sum of Digits of an Integer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1281.Subtract-the-Product-and-Sum-of-Digits-of-an-Integer)|85.6%|Easy|| |1282|Group the People Given the Group Size They Belong To||84.4%|Medium|| -|1283|Find the Smallest Divisor Given a Threshold|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1283.Find-the-Smallest-Divisor-Given-a-Threshold)|49.4%|Medium|| +|1283|Find the Smallest Divisor Given a Threshold|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1283.Find-the-Smallest-Divisor-Given-a-Threshold)|49.5%|Medium|| |1284|Minimum Number of Flips to Convert Binary Matrix to Zero Matrix||70.2%|Hard|| |1285|Find the Start and End Number of Continuous Ranges||87.0%|Medium|| |1286|Iterator for Combination||70.9%|Medium|| @@ -1458,29 +1458,29 @@ |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.4%|Medium|| |1320|Minimum Distance to Type a Word Using Two Fingers||62.1%|Hard|| -|1321|Restaurant Growth||71.0%|Medium|| -|1322|Ads Performance||57.9%|Easy|| -|1323|Maximum 69 Number||77.9%|Easy|| +|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|| |1325|Delete Leaves With a Given Value||73.7%|Medium|| |1326|Minimum Number of Taps to Open to Water a Garden||46.5%|Hard|| |1327|List the Products Ordered in a Period||77.5%|Easy|| -|1328|Break a Palindrome||46.2%|Medium|| +|1328|Break a Palindrome||46.3%|Medium|| |1329|Sort the Matrix Diagonally|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1329.Sort-the-Matrix-Diagonally)|81.8%|Medium|| |1330|Reverse Subarray To Maximize Array Value||36.6%|Hard|| |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.9%|Medium|| +|1334|Find the City With the Smallest Number of Neighbors at a Threshold Distance||46.8%|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.7%|Medium|| +|1336|Number of Transactions per Visit||47.9%|Hard|| +|1337|The K Weakest Rows in a Matrix||70.4%|Easy|| +|1338|Reduce Array Size to The Half||67.6%|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.9%|Easy|| -|1343|Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold||64.8%|Medium|| +|1343|Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold||64.7%|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|| @@ -1506,9 +1506,9 @@ |1366|Rank Teams by Votes||55.1%|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|| +|1369|Get the Second Most Recent Activity||68.8%|Hard|| |1370|Increasing Decreasing String||76.5%|Easy|| -|1371|Find the Longest Substring Containing Vowels in Even Counts||61.0%|Medium|| +|1371|Find the Longest Substring Containing Vowels in Even Counts||60.9%|Medium|| |1372|Longest ZigZag Path in a Binary Tree||54.9%|Medium|| |1373|Maximum Sum BST in Binary Tree||37.3%|Hard|| |1374|Generate a String With Characters That Have Odd Counts||76.2%|Easy|| @@ -1520,7 +1520,7 @@ |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|| -|1383|Maximum Performance of a Team||35.5%|Hard|| +|1383|Maximum Performance of a Team||35.6%|Hard|| |1384|Total Sales Amount by Year||64.6%|Hard|| |1385|Find the Distance Value Between Two Arrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1385.Find-the-Distance-Value-Between-Two-Arrays)|66.4%|Easy|| |1386|Cinema Seat Allocation||35.8%|Medium|| @@ -1532,7 +1532,7 @@ |1392|Longest Happy Prefix||41.8%|Hard|| |1393|Capital Gain/Loss||90.5%|Medium|| |1394|Find Lucky Integer in an Array||63.2%|Easy|| -|1395|Count Number of Teams||78.6%|Medium|| +|1395|Count Number of Teams||78.5%|Medium|| |1396|Design Underground System||69.5%|Medium|| |1397|Find All Good Strings||38.4%|Hard|| |1398|Customers Who Bought Products A and B but Not C||81.9%|Medium|| @@ -1544,20 +1544,20 @@ |1404|Number of Steps to Reduce a Number in Binary Representation to One||50.0%|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|| -|1409|Queries on a Permutation With Key||81.6%|Medium|| +|1407|Top Travellers||83.6%|Easy|| +|1408|String Matching in an Array||62.8%|Easy|| +|1409|Queries on a Permutation With Key||81.5%|Medium|| |1410|HTML Entity Parser||54.4%|Medium|| |1411|Number of Ways to Paint N × 3 Grid||60.4%|Hard|| -|1412|Find the Quiet Students in All Exams||65.1%|Hard|| +|1412|Find the Quiet Students in All Exams||64.9%|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.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|| +|1417|Reformat The String||55.2%|Easy|| +|1418|Display Table of Food Orders in a Restaurant||68.8%|Medium|| |1419|Minimum Number of Frogs Croaking||47.4%|Medium|| -|1420|Build Array Where You Can Find The Maximum Exactly K Comparisons||64.4%|Hard|| +|1420|Build Array Where You Can Find The Maximum Exactly K Comparisons||64.3%|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|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1423.Maximum-Points-You-Can-Obtain-from-Cards)|46.6%|Medium|| @@ -1572,13 +1572,13 @@ |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.3%|Hard|| -|1435|Create a Session Bar Chart||77.7%|Easy|| +|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|| |1439|Find the Kth Smallest Sum of a Matrix With Sorted Rows|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1439.Find-the-Kth-Smallest-Sum-of-a-Matrix-With-Sorted-Rows)|60.1%|Hard|| |1440|Evaluate Boolean Expression||74.4%|Medium|| -|1441|Build an Array With Stack Operations||69.8%|Easy|| +|1441|Build an Array With Stack Operations||69.9%|Easy|| |1442|Count Triplets That Can Form Two Arrays of Equal XOR||71.3%|Medium|| |1443|Minimum Time to Collect All Apples in a Tree||54.6%|Medium|| |1444|Number of Ways of Cutting a Pizza||53.7%|Hard|| @@ -1591,15 +1591,15 @@ |1451|Rearrange Words in a Sentence||59.4%|Medium|| |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|| +|1454|Active Users||38.9%|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.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|| +|1459|Rectangles Area||64.6%|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.5%|Medium|| +|1462|Course Schedule IV||44.6%|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.6%|Medium|| @@ -1616,7 +1616,7 @@ |1476|Subrectangle Queries||88.4%|Medium|| |1477|Find Two Non-overlapping Sub-arrays Each With Target Sum||34.4%|Medium|| |1478|Allocate Mailboxes||54.0%|Hard|| -|1479|Sales by Day of the Week||83.9%|Hard|| +|1479|Sales by Day of the Week||83.8%|Hard|| |1480|Running Sum of 1d Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1480.Running-Sum-of-1d-Array)|89.2%|Easy|| |1481|Least Number of Unique Integers after K Removals||55.8%|Medium|| |1482|Minimum Number of Days to Make m Bouquets||50.0%|Medium|| @@ -1634,25 +1634,25 @@ |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|| -|1498|Number of Subsequences That Satisfy the Given Sum Condition||38.3%|Medium|| -|1499|Max Value of Equation||45.3%|Hard|| +|1497|Check If Array Pairs Are Divisible by k||40.4%|Medium|| +|1498|Number of Subsequences That Satisfy the Given Sum Condition||38.4%|Medium|| +|1499|Max Value of Equation||45.2%|Hard|| |1500|Design a File Sharing System||46.8%|Medium|| |1501|Countries You Can Safely Invest In||60.5%|Medium|| |1502|Can Make Arithmetic Progression From Sequence||71.2%|Easy|| |1503|Last Moment Before All Ants Fall Out of a Plank||53.1%|Medium|| -|1504|Count Submatrices With All Ones||60.9%|Medium|| +|1504|Count Submatrices With All Ones||61.0%|Medium|| |1505|Minimum Possible Integer After at Most K Adjacent Swaps On Digits||36.3%|Hard|| |1506|Find Root of N-Ary Tree||80.4%|Medium|| |1507|Reformat Date||60.1%|Easy|| |1508|Range Sum of Sorted Subarray Sums||61.2%|Medium|| |1509|Minimum Difference Between Largest and Smallest Value in Three Moves||52.0%|Medium|| |1510|Stone Game IV||58.8%|Hard|| -|1511|Customer Order Frequency||73.7%|Easy|| +|1511|Customer Order Frequency||73.8%|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||40.0%|Medium|| -|1515|Best Position for a Service Centre||37.0%|Hard|| +|1515|Best Position for a Service Centre||36.8%|Hard|| |1516|Move Sub-Tree of N-Ary Tree||63.2%|Hard|| |1517|Find Users With Valid E-Mails||71.9%|Easy|| |1518|Water Bottles||60.6%|Easy|| @@ -1664,12 +1664,12 @@ |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.1%|Easy|| -|1528|Shuffle String||85.8%|Easy|| +|1527|Patients With a Condition||68.8%|Easy|| +|1528|Shuffle String||85.7%|Easy|| |1529|Bulb Switcher IV||70.9%|Medium|| |1530|Number of Good Leaf Nodes Pairs||56.2%|Medium|| |1531|String Compression II||33.8%|Hard|| -|1532|The Most Recent Three Orders||72.9%|Medium|| +|1532|The Most Recent Three Orders||72.8%|Medium|| |1533|Find the Index of the Large Integer||54.6%|Medium|| |1534|Count Good Triplets||80.4%|Easy|| |1535|Find the Winner of an Array Game||47.4%|Medium|| @@ -1690,7 +1690,7 @@ |1550|Three Consecutive Odds||64.9%|Easy|| |1551|Minimum Operations to Make Array Equal||77.9%|Medium|| |1552|Magnetic Force Between Two Balls||48.9%|Medium|| -|1553|Minimum Number of Days to Eat N Oranges||29.5%|Hard|| +|1553|Minimum Number of Days to Eat N Oranges||29.6%|Hard|| |1554|Strings Differ by One Character||63.4%|Medium|| |1555|Bank Account Summary||52.7%|Medium|| |1556|Thousand Separator||57.8%|Easy|| @@ -1698,57 +1698,57 @@ |1558|Minimum Numbers of Function Calls to Make Target Array||63.5%|Medium|| |1559|Detect Cycles in 2D Grid||44.4%|Hard|| |1560|Most Visited Sector in a Circular Track||56.9%|Easy|| -|1561|Maximum Number of Coins You Can Get||77.7%|Medium|| +|1561|Maximum Number of Coins You Can Get||77.6%|Medium|| |1562|Find Latest Group of Size M||39.5%|Medium|| -|1563|Stone Game V||40.1%|Hard|| +|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.9%|Easy|| +|1565|Unique Orders and Customers Per Month||83.0%|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|| -|1569|Number of Ways to Reorder Array to Get Same BST||50.0%|Hard|| +|1569|Number of Ways to Reorder Array to Get Same BST||50.1%|Hard|| |1570|Dot Product of Two Sparse Vectors||91.2%|Medium|| |1571|Warehouse Manager||89.8%|Easy|| |1572|Matrix Diagonal Sum||78.2%|Easy|| -|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|| +|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.1%|Medium|| +|1574|Shortest Subarray to be Removed to Make Array Sorted||33.4%|Medium|| |1575|Count All Possible Routes||57.3%|Hard|| |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|[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|| +|1580|Put Boxes Into the Warehouse II||61.9%|Medium|| |1581|Customer Who Visited but Did Not Make Any Transactions||89.7%|Easy|| |1582|Special Positions in a Binary Matrix||64.4%|Easy|| |1583|Count Unhappy Friends||54.3%|Medium|| -|1584|Min Cost to Connect All Points||51.6%|Medium|| +|1584|Min Cost to Connect All Points||51.7%|Medium|| |1585|Check If String Is Transformable With Substring Sort Operations||48.2%|Hard|| -|1586|Binary Search Tree Iterator II||66.5%|Medium|| +|1586|Binary Search Tree Iterator II||66.6%|Medium|| |1587|Bank Account Summary II||89.9%|Easy|| |1588|Sum of All Odd Length Subarrays||82.0%|Easy|| |1589|Maximum Sum Obtained of Any Permutation||34.7%|Medium|| -|1590|Make Sum Divisible by P||27.0%|Medium|| +|1590|Make Sum Divisible by P||27.1%|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|| |1594|Maximum Non Negative Product in a Matrix||32.0%|Medium|| -|1595|Minimum Cost to Connect Two Groups of Points||42.9%|Hard|| -|1596|The Most Frequently Ordered Products for Each Customer||84.0%|Medium|| -|1597|Build Binary Expression Tree From Infix Expression||63.0%|Hard|| +|1595|Minimum Cost to Connect Two Groups of Points||43.0%|Hard|| +|1596|The Most Frequently Ordered Products for Each Customer||84.1%|Medium|| +|1597|Build Binary Expression Tree From Infix Expression||62.9%|Hard|| |1598|Crawler Log Folder||64.1%|Easy|| |1599|Maximum Profit of Operating a Centennial Wheel||43.6%|Medium|| |1600|Throne Inheritance||60.2%|Medium|| |1601|Maximum Number of Achievable Transfer Requests||47.8%|Hard|| |1602|Find Nearest Right Node in Binary Tree||73.9%|Medium|| -|1603|Design Parking System||86.5%|Easy|| +|1603|Design Parking System|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/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||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|| +|1608|Special Array With X Elements Greater Than or Equal X|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X)|61.6%|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.5%|Hard|| +|1610|Maximum Number of Visible Points||29.3%|Hard|| +|1611|Minimum One Bit Operations to Make Integers Zero||57.6%|Hard|| |1612|Check If Two Expression Trees are Equivalent||69.8%|Medium|| |1613|Find the Missing IDs||73.4%|Medium|| |1614|Maximum Nesting Depth of the Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1614.Maximum-Nesting-Depth-of-the-Parentheses)|83.0%|Easy|| @@ -1762,56 +1762,56 @@ |1622|Fancy Sequence||15.3%|Hard|| |1623|All Valid Triplets That Can Represent a Country||88.4%|Easy|| |1624|Largest Substring Between Two Equal Characters|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/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|| +|1625|Lexicographically Smallest String After Applying Operations||63.9%|Medium|| +|1626|Best Team With No Conflicts||37.8%|Medium|| |1627|Graph Connectivity With Threshold||38.6%|Hard|| -|1628|Design an Expression Tree With Evaluate Function||80.5%|Medium|| +|1628|Design an Expression Tree With Evaluate Function||80.6%|Medium|| |1629|Slowest Key|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1629.Slowest-Key)|59.2%|Easy|| -|1630|Arithmetic Subarrays||77.7%|Medium|| +|1630|Arithmetic Subarrays||77.6%|Medium|| |1631|Path With Minimum Effort|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/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||71.8%|Easy|| |1634|Add Two Polynomials Represented as Linked Lists||55.5%|Medium|| -|1635|Hopper Company Queries I||56.4%|Hard|| +|1635|Hopper Company Queries I||56.6%|Hard|| |1636|Sort Array by Increasing Frequency|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/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.9%|Medium|| -|1639|Number of Ways to Form a Target String Given a Dictionary||39.5%|Hard|| +|1638|Count Substrings That Differ by One Character||68.8%|Medium|| +|1639|Number of Ways to Form a Target String Given a Dictionary||39.6%|Hard|| |1640|Check Array Formation Through Concatenation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1640.Check-Array-Formation-Through-Concatenation)|60.1%|Easy|| -|1641|Count Sorted Vowel Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1641.Count-Sorted-Vowel-Strings)|76.9%|Medium|| +|1641|Count Sorted Vowel Strings|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1641.Count-Sorted-Vowel-Strings)|76.8%|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.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.4%|Easy|| +|1644|Lowest Common Ancestor of a Binary Tree II||57.1%|Medium|| +|1645|Hopper Company Queries II||39.2%|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|| +|1648|Sell Diminishing-Valued Colored Balls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1648.Sell-Diminishing-Valued-Colored-Balls)|30.7%|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||77.0%|Medium|| -|1651|Hopper Company Queries III||67.5%|Hard|| +|1650|Lowest Common Ancestor of a Binary Tree III||76.8%|Medium|| +|1651|Hopper Company Queries III||66.4%|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.5%|Medium|| |1654|Minimum Jumps to Reach Home|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1654.Minimum-Jumps-to-Reach-Home)|26.0%|Medium|| -|1655|Distribute Repeating Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1655.Distribute-Repeating-Integers)|40.3%|Hard|| +|1655|Distribute Repeating Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1655.Distribute-Repeating-Integers)|40.4%|Hard|| |1656|Design an Ordered Stream|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1656.Design-an-Ordered-Stream)|82.3%|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.5%|Medium|| -|1661|Average Time of Process per Machine||79.3%|Easy|| +|1660|Correct a Binary Tree||77.2%|Medium|| +|1661|Average Time of Process per Machine||79.5%|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.2%|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)|61.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.3%|Medium|| -|1667|Fix Names in a Table||63.6%|Easy|| -|1668|Maximum Repeating Substring|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1668.Maximum-Repeating-Substring)|38.5%|Easy|| +|1666|Change the Root of a Binary Tree||67.9%|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.6%|Easy|| |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|| +|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|| |1671|Minimum Number of Removals to Make Mountain Array||45.6%|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.8%|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.6%|Medium|| |1677|Product's Worth Over Invoices||73.9%|Easy|| @@ -1822,83 +1822,83 @@ |1682|Longest Palindromic Subsequence II||50.4%|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.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|| +|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.8%|Medium|| +|1686|Stone Game VI||49.1%|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.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|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1691.Maximum-Height-by-Stacking-Cuboids)|50.0%|Hard|| -|1692|Count Ways to Distribute Candies||62.3%|Hard|| +|1691|Maximum Height by Stacking Cuboids|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1691.Maximum-Height-by-Stacking-Cuboids)|49.9%|Hard|| +|1692|Count Ways to Distribute Candies||62.4%|Hard|| |1693|Daily Leads and Partners||91.0%|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)|53.8%|Medium|| -|1697|Checking Existence of Edge Length Limited Paths||55.8%|Hard|| -|1698|Number of Distinct Substrings in a String||57.0%|Medium|| +|1697|Checking Existence of Edge Length Limited Paths||55.9%|Hard|| +|1698|Number of Distinct Substrings in a String||57.2%|Medium|| |1699|Number of Calls Between Two Persons||86.6%|Medium|| -|1700|Number of Students Unable to Eat Lunch||68.9%|Easy|| -|1701|Average Waiting Time||61.5%|Medium|| +|1700|Number of Students Unable to Eat Lunch|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch)|68.9%|Easy|| +|1701|Average Waiting Time||61.4%|Medium|| |1702|Maximum Binary String After Change||60.6%|Medium|| |1703|Minimum Adjacent Swaps for K Consecutive Ones||40.3%|Hard|| |1704|Determine if String Halves Are Alike|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1704.Determine-if-String-Halves-Are-Alike)|77.6%|Easy|| -|1705|Maximum Number of Eaten Apples||42.0%|Medium|| +|1705|Maximum Number of Eaten Apples||42.1%|Medium|| |1706|Where Will the Ball Fall||59.2%|Medium|| -|1707|Maximum XOR With an Element From Array||47.2%|Hard|| +|1707|Maximum XOR With an Element From Array||47.1%|Hard|| |1708|Largest Subarray Length K||64.0%|Easy|| -|1709|Biggest Window Between Visits||82.5%|Medium|| -|1710|Maximum Units on a Truck||70.5%|Easy|| -|1711|Count Good Meals||26.1%|Medium|| +|1709|Biggest Window Between Visits||82.6%|Medium|| +|1710|Maximum Units on a Truck|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1710.Maximum-Units-on-a-Truck)|70.5%|Easy|| +|1711|Count Good Meals||26.0%|Medium|| |1712|Ways to Split Array Into Three Subarrays||29.8%|Medium|| |1713|Minimum Operations to Make a Subsequence||45.5%|Hard|| -|1714|Sum Of Special Evenly-Spaced Elements In Array||47.8%|Hard|| +|1714|Sum Of Special Evenly-Spaced Elements In Array||48.0%|Hard|| |1715|Count Apples and Oranges||79.2%|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|| -|1720|Decode XORed Array||85.7%|Easy|| +|1716|Calculate Money in Leetcode Bank|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1716.Calculate-Money-in-Leetcode-Bank)|67.3%|Easy|| +|1717|Maximum Score From Removing Substrings||40.0%|Medium|| +|1718|Construct the Lexicographically Largest Valid Sequence||44.9%|Medium|| +|1719|Number Of Ways To Reconstruct A Tree||39.0%|Hard|| +|1720|Decode XORed Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1720.Decode-XORed-Array)|85.7%|Easy|| |1721|Swapping Nodes in a Linked List||64.7%|Medium|| -|1722|Minimize Hamming Distance After Swap Operations||55.0%|Medium|| +|1722|Minimize Hamming Distance After Swap Operations||54.9%|Medium|| |1723|Find Minimum Time to Finish All Jobs||44.2%|Hard|| |1724|Checking Existence of Edge Length Limited Paths II||59.0%|Hard|| -|1725|Number Of Rectangles That Can Form The Largest Square||77.8%|Easy|| +|1725|Number Of Rectangles That Can Form The Largest Square|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square)|77.8%|Easy|| |1726|Tuple with Same Product||55.4%|Medium|| -|1727|Largest Submatrix With Rearrangements||58.3%|Medium|| +|1727|Largest Submatrix With Rearrangements||58.4%|Medium|| |1728|Cat and Mouse II||41.0%|Hard|| |1729|Find Followers Count||72.2%|Easy|| -|1730|Shortest Path to Get Food||58.3%|Medium|| -|1731|The Number of Employees Which Report to Each Employee||49.6%|Easy|| -|1732|Find the Highest Altitude||81.7%|Easy|| +|1730|Shortest Path to Get Food||58.1%|Medium|| +|1731|The Number of Employees Which Report to Each Employee||49.5%|Easy|| +|1732|Find the Highest Altitude|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1732.Find-the-Highest-Altitude)|81.6%|Easy|| |1733|Minimum Number of People to Teach||36.7%|Medium|| -|1734|Decode XORed Permutation||51.0%|Medium|| +|1734|Decode XORed Permutation||51.1%|Medium|| |1735|Count Ways to Make Array With Product||48.9%|Hard|| -|1736|Latest Time by Replacing Hidden Digits||41.2%|Easy|| -|1737|Change Minimum Characters to Satisfy One of Three Conditions||29.1%|Medium|| +|1736|Latest Time by Replacing Hidden Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits)|41.1%|Easy|| +|1737|Change Minimum Characters to Satisfy One of Three Conditions||29.2%|Medium|| |1738|Find Kth Largest XOR Coordinate Value||62.4%|Medium|| -|1739|Building Boxes||49.5%|Hard|| +|1739|Building Boxes||49.4%|Hard|| |1740|Find Distance in a Binary Tree||71.0%|Medium|| -|1741|Find Total Time Spent by Each Employee||90.9%|Easy|| -|1742|Maximum Number of Balls in a Box||74.8%|Easy|| +|1741|Find Total Time Spent by Each Employee||91.1%|Easy|| +|1742|Maximum Number of Balls in a Box|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1742.Maximum-Number-of-Balls-in-a-Box)|74.8%|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.7%|Medium|| -|1747|Leetflex Banned Accounts||68.6%|Medium|| -|1748|Sum of Unique Elements||77.3%|Easy|| -|1749|Maximum Absolute Sum of Any Subarray||50.0%|Medium|| -|1750|Minimum Length of String After Deleting Similar Ends||41.6%|Medium|| +|1745|Palindrome Partitioning IV||48.7%|Hard|| +|1746|Maximum Subarray Sum After One Operation||62.5%|Medium|| +|1747|Leetflex Banned Accounts||68.2%|Medium|| +|1748|Sum of Unique Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1748.Sum-of-Unique-Elements)|77.3%|Easy|| +|1749|Maximum Absolute Sum of Any Subarray||50.2%|Medium|| +|1750|Minimum Length of String After Deleting Similar Ends||41.8%|Medium|| |1751|Maximum Number of Events That Can Be Attended II||47.4%|Hard|| -|1752|Check if Array Is Sorted and Rotated||68.8%|Easy|| +|1752|Check if Array Is Sorted and Rotated|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated)|68.3%|Easy|| |1753|Maximum Score From Removing Stones||60.5%|Medium|| -|1754|Largest Merge Of Two Strings||38.7%|Medium|| -|1755|Closest Subsequence Sum||35.7%|Hard|| -|1756|Design Most Recently Used Queue||78.8%|Medium|| -|1757|Recyclable and Low Fat Products||98.0%|Easy|| -|1758|Minimum Changes To Make Alternating Binary String||58.0%|Easy|| -|1759|Count Number of Homogenous Substrings||34.8%|Medium|| -|1760|Minimum Limit of Balls in a Bag||34.6%|Medium|| -|1761|Minimum Degree of a Connected Trio in a Graph||20.6%|Hard|| +|1754|Largest Merge Of Two Strings||39.0%|Medium|| +|1755|Closest Subsequence Sum||35.8%|Hard|| +|1756|Design Most Recently Used Queue||77.3%|Medium|| +|1757|Recyclable and Low Fat Products||98.2%|Easy|| +|1758|Minimum Changes To Make Alternating Binary String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String)|60.8%|Easy|| +|1759|Count Number of Homogenous Substrings||39.6%|Medium|| +|1760|Minimum Limit of Balls in a Bag||48.2%|Medium|| +|1761|Minimum Degree of a Connected Trio in a Graph||31.7%|Hard|| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------| ------------------------------------------------------------------ diff --git a/leetcode/1603.Design-Parking-System/1603. Design Parking System.go b/leetcode/1603.Design-Parking-System/1603. Design Parking System.go new file mode 100644 index 000000000..86c9c60a5 --- /dev/null +++ b/leetcode/1603.Design-Parking-System/1603. Design Parking System.go @@ -0,0 +1,51 @@ +package leetcode + +type ParkingSystem struct { + Big int + Medium int + Small int +} + +func Constructor(big int, medium int, small int) ParkingSystem { + return ParkingSystem{ + Big: big, + Medium: medium, + Small: small, + } +} + +func (this *ParkingSystem) AddCar(carType int) bool { + switch carType { + case 1: + { + if this.Big > 0 { + this.Big-- + return true + } + return false + } + case 2: + { + if this.Medium > 0 { + this.Medium-- + return true + } + return false + } + case 3: + { + if this.Small > 0 { + this.Small-- + return true + } + return false + } + } + return false +} + +/** + * Your ParkingSystem object will be instantiated and called as such: + * obj := Constructor(big, medium, small); + * param_1 := obj.AddCar(carType); + */ diff --git a/leetcode/1603.Design-Parking-System/1603. Design Parking System_test.go b/leetcode/1603.Design-Parking-System/1603. Design Parking System_test.go new file mode 100644 index 000000000..9fa635702 --- /dev/null +++ b/leetcode/1603.Design-Parking-System/1603. Design Parking System_test.go @@ -0,0 +1,15 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +func Test_Problem1603(t *testing.T) { + obj := Constructor(1, 1, 0) + fmt.Printf("obj = %v\n", obj) + fmt.Printf("obj = %v\n", obj.AddCar(1)) + fmt.Printf("obj = %v\n", obj.AddCar(2)) + fmt.Printf("obj = %v\n", obj.AddCar(3)) + fmt.Printf("obj = %v\n", obj.AddCar(1)) +} diff --git a/leetcode/1603.Design-Parking-System/README.md b/leetcode/1603.Design-Parking-System/README.md new file mode 100644 index 000000000..b4a5a8fe7 --- /dev/null +++ b/leetcode/1603.Design-Parking-System/README.md @@ -0,0 +1,103 @@ +# [1603. Design Parking System](https://leetcode.com/problems/design-parking-system/) + + +## 题目 + +Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. + +Implement the `ParkingSystem` class: + +- `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slots for each parking space are given as part of the constructor. +- `bool addCar(int carType)` Checks whether there is a parking space of `carType` for the car that wants to get into the parking lot. `carType` can be of three kinds: big, medium, or small, which are represented by `1`, `2`, and `3` respectively. **A car can only park in a parking space of its** `carType`. If there is no space available, return `false`, else park the car in that size space and return `true`. + +**Example 1:** + +``` +Input +["ParkingSystem", "addCar", "addCar", "addCar", "addCar"] +[[1, 1, 0], [1], [2], [3], [1]] +Output +[null, true, true, false, false] + +Explanation +ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0); +parkingSystem.addCar(1); // return true because there is 1 available slot for a big car +parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car +parkingSystem.addCar(3); // return false because there is no available slot for a small car +parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied. +``` + +**Constraints:** + +- `0 <= big, medium, small <= 1000` +- `carType` is `1`, `2`, or `3` +- At most `1000` calls will be made to `addCar` + +## 题目大意 + +请你给一个停车场设计一个停车系统。停车场总共有三种不同大小的车位:大,中和小,每种尺寸分别有固定数目的车位。 + +请你实现 ParkingSystem 类: + +- ParkingSystem(int big, int medium, int small) 初始化 ParkingSystem 类,三个参数分别对应每种停车位的数目。 +- bool addCar(int carType) 检查是否有 carType 对应的停车位。 carType 有三种类型:大,中,小,分别用数字 1, 2 和 3 表示。一辆车只能停在 carType 对应尺寸的停车位中。如果没有空车位,请返回 false ,否则将该车停入车位并返回 true 。 + +## 解题思路 + +- 简单题。分别用 3 个变量表示大,中和小车位。`addCar()` 判断这 3 个变量是否还有空车位即可。 + +## 代码 + +```go +package leetcode + +type ParkingSystem struct { + Big int + Medium int + Small int +} + +func Constructor(big int, medium int, small int) ParkingSystem { + return ParkingSystem{ + Big: big, + Medium: medium, + Small: small, + } +} + +func (this *ParkingSystem) AddCar(carType int) bool { + switch carType { + case 1: + { + if this.Big > 0 { + this.Big-- + return true + } + return false + } + case 2: + { + if this.Medium > 0 { + this.Medium-- + return true + } + return false + } + case 3: + { + if this.Small > 0 { + this.Small-- + return true + } + return false + } + } + return false +} + +/** + * Your ParkingSystem object will be instantiated and called as such: + * obj := Constructor(big, medium, small); + * param_1 := obj.AddCar(carType); + */ +``` \ No newline at end of file diff --git a/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X.go b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X.go new file mode 100644 index 000000000..27ea1e025 --- /dev/null +++ b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X.go @@ -0,0 +1,18 @@ +package leetcode + +import "sort" + +func specialArray(nums []int) int { + sort.Ints(nums) + x := len(nums) + for _, num := range nums { + if num >= x { + return x + } + x-- + if num >= x { + return -1 + } + } + return -1 +} diff --git a/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X_test.go b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X_test.go new file mode 100644 index 000000000..5d17d1c46 --- /dev/null +++ b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/1608. Special Array With X Elements Greater Than or Equal X_test.go @@ -0,0 +1,57 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1608 struct { + para1608 + ans1608 +} + +// para 是参数 +// one 代表第一个参数 +type para1608 struct { + nums []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1608 struct { + one int +} + +func Test_Problem1608(t *testing.T) { + + qs := []question1608{ + + { + para1608{[]int{3, 5}}, + ans1608{2}, + }, + + { + para1608{[]int{0, 0}}, + ans1608{-1}, + }, + + { + para1608{[]int{0, 4, 3, 0, 4}}, + ans1608{3}, + }, + + { + para1608{[]int{3, 6, 7, 7, 0}}, + ans1608{-1}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1608------------------------\n") + + for _, q := range qs { + _, p := q.ans1608, q.para1608 + fmt.Printf("【input】:%v 【output】:%v \n", p, specialArray(p.nums)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/README.md b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/README.md new file mode 100644 index 000000000..96ac718ac --- /dev/null +++ b/leetcode/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X/README.md @@ -0,0 +1,80 @@ +# [1608. Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/) + +## 题目 + +You are given an array `nums` of non-negative integers. `nums` is considered **special** if there exists a number `x` such that there are **exactly** `x` numbers in `nums` that are **greater than or equal to** `x`. + +Notice that `x` **does not** have to be an element in `nums`. + +Return `x` *if the array is **special**, otherwise, return* `-1`. It can be proven that if `nums` is special, the value for `x` is **unique**. + +**Example 1:** + +``` +Input: nums = [3,5] +Output: 2 +Explanation: There are 2 values (3 and 5) that are greater than or equal to 2. +``` + +**Example 2:** + +``` +Input: nums = [0,0] +Output: -1 +Explanation: No numbers fit the criteria for x. +If x = 0, there should be 0 numbers >= x, but there are 2. +If x = 1, there should be 1 number >= x, but there are 0. +If x = 2, there should be 2 numbers >= x, but there are 0. +x cannot be greater since there are only 2 numbers in nums. +``` + +**Example 3:** + +``` +Input: nums = [0,4,3,0,4] +Output: 3 +Explanation: There are 3 values that are greater than or equal to 3. +``` + +**Example 4:** + +``` +Input: nums = [3,6,7,7,0] +Output: -1 +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `0 <= nums[i] <= 1000` + +## 题目大意 + +给你一个非负整数数组 nums 。如果存在一个数 x ,使得 nums 中恰好有 x 个元素 大于或者等于 x ,那么就称 nums 是一个 特殊数组 ,而 x 是该数组的 特征值 。(注意: x 不必 是 nums 的中的元素。)如果数组 nums 是一个 特殊数组 ,请返回它的特征值 x 。否则,返回 -1 。可以证明的是,如果 nums 是特殊数组,那么其特征值 x 是 唯一的 。 + +## 解题思路 + +- 简单题。抓住题干中给的证明,特征值是唯一的。先将数组从小到大排序,下标的含义与特征值就等价了。下标 `i` 代表大于等于 `nums[i]` 的元素有 `len(nums) - i` 个,那么从第 0 个下标的元素开始遍历,如果这个元素都大于 `len(nums)`,那么后面 `len(nums)` 个元素也都大于等于它,特征值就找到了。如果特征值减一以后,仍然满足 `nums[i] >= x`,说明满足条件的值有多个,这一点不满足特征值唯一性,可以直接返回 -1 了。下标继续右移,特征值继续减一。如果最终循环结束依旧找不到特征值,返回 -1 。 + +## 代码 + +```go +package leetcode + +import "sort" + +func specialArray(nums []int) int { + sort.Ints(nums) + x := len(nums) + for _, num := range nums { + if num >= x { + return x + } + x-- + if num >= x { + return -1 + } + } + return -1 +} +``` \ No newline at end of file diff --git a/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch.go b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch.go new file mode 100644 index 000000000..a956a03ff --- /dev/null +++ b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch.go @@ -0,0 +1,13 @@ +package leetcode + +func countStudents(students []int, sandwiches []int) int { + tmp, n, i := [2]int{}, len(students), 0 + for _, v := range students { + tmp[v]++ + } + for i < n && tmp[sandwiches[i]] > 0 { + tmp[sandwiches[i]]-- + i++ + } + return n - i +} diff --git a/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch_test.go b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch_test.go new file mode 100644 index 000000000..d407a9687 --- /dev/null +++ b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/1700. Number of Students Unable to Eat Lunch_test.go @@ -0,0 +1,48 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1700 struct { + para1700 + ans1700 +} + +// para 是参数 +// one 代表第一个参数 +type para1700 struct { + students []int + sandwiches []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1700 struct { + one int +} + +func Test_Problem1700(t *testing.T) { + + qs := []question1700{ + + { + para1700{[]int{1, 1, 0, 0}, []int{0, 1, 0, 1}}, + ans1700{0}, + }, + + { + para1700{[]int{1, 1, 1, 0, 0, 1}, []int{1, 0, 0, 0, 1, 1}}, + ans1700{3}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1700------------------------\n") + + for _, q := range qs { + _, p := q.ans1700, q.para1700 + fmt.Printf("【input】:%v 【output】:%v\n", p, countStudents(p.students, p.sandwiches)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/README.md b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/README.md new file mode 100644 index 000000000..1ff50247b --- /dev/null +++ b/leetcode/1700.Number-of-Students-Unable-to-Eat-Lunch/README.md @@ -0,0 +1,79 @@ +# [1700. Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/) + + +## 题目 + +The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students stand in a queue. Each student either prefers square or circular sandwiches. + +The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a **stack**. At each step: + +- If the student at the front of the queue **prefers** the sandwich on the top of the stack, they will **take it** and leave the queue. +- Otherwise, they will **leave it** and go to the queue's end. + +This continues until none of the queue students want to take the top sandwich and are thus unable to eat. + +You are given two integer arrays `students` and `sandwiches` where `sandwiches[i]` is the type of the `ith` sandwich in the stack (`i = 0` is the top of the stack) and `students[j]` is the preference of the `jth` student in the initial queue (`j = 0` is the front of the queue). Return *the number of students that are unable to eat.* + +**Example 1:** + +``` +Input: students = [1,1,0,0], sandwiches = [0,1,0,1] +Output: 0 +Explanation: +- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1]. +- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0]. +- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [0,1]. +- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1]. +- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = []. +Hence all students are able to eat. +``` + +**Example 2:** + +``` +Input: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1] +Output: 3 +``` + +**Constraints:** + +- `1 <= students.length, sandwiches.length <= 100` +- `students.length == sandwiches.length` +- `sandwiches[i]` is `0` or `1`. +- `students[i]` is `0` or `1`. + +## 题目大意 + +学校的自助午餐提供圆形和方形的三明治,分别用数字 0 和 1 表示。所有学生站在一个队列里,每个学生要么喜欢圆形的要么喜欢方形的。 +餐厅里三明治的数量与学生的数量相同。所有三明治都放在一个 栈 里,每一轮: + +- 如果队列最前面的学生 喜欢 栈顶的三明治,那么会 拿走它 并离开队列。 +- 否则,这名学生会 放弃这个三明治 并回到队列的尾部。 +这个过程会一直持续到队列里所有学生都不喜欢栈顶的三明治为止。 + +给你两个整数数组 students 和 sandwiches ,其中 sandwiches[i] 是栈里面第 i 个三明治的类型(i = 0 是栈的顶部), students[j] 是初始队列里第 j 名学生对三明治的喜好(j = 0 是队列的最开始位置)。请你返回无法吃午餐的学生数量。 + +## 解题思路 + +- 简单题。按照题意,学生不管怎么轮流领三明治,如果数量够,经过多轮循环,总能领到。问题可以等价为,学生依次到队列前面领取三明治。2 个种类的三明治都摆好放在那里了。最终领不到三明治的学生都是因为喜欢的三明治不够发放了。按照这个思路,先统计 2 种三明治的总个数,然后减去学生对三明治的需求总数,剩下的学生即都是无法满足的。 + +## 代码 + +```go +package leetcode + +func countStudents(students []int, sandwiches []int) int { + tmp, n, i := [2]int{}, len(students), 0 + for _, v := range students { + tmp[v]++ + } + for i < n && tmp[sandwiches[i]] > 0 { + tmp[sandwiches[i]]-- + i++ + } + return n - i +} +``` \ No newline at end of file diff --git a/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck.go b/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck.go new file mode 100644 index 000000000..7caf40e83 --- /dev/null +++ b/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck.go @@ -0,0 +1,20 @@ +package leetcode + +import "sort" + +func maximumUnits(boxTypes [][]int, truckSize int) int { + sort.Slice(boxTypes, func(i, j int) bool { + return boxTypes[i][1] > boxTypes[j][1] + }) + res := 0 + for i := 0; truckSize > 0 && i < len(boxTypes); i++ { + if truckSize >= boxTypes[i][0] { + truckSize -= boxTypes[i][0] + res += (boxTypes[i][1] * boxTypes[i][0]) + } else { + res += (truckSize * boxTypes[i][1]) + truckSize = 0 + } + } + return res +} diff --git a/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck_test.go b/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck_test.go new file mode 100644 index 000000000..2c2b216da --- /dev/null +++ b/leetcode/1710.Maximum-Units-on-a-Truck/1710. Maximum Units on a Truck_test.go @@ -0,0 +1,48 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1710 struct { + para1710 + ans1710 +} + +// para 是参数 +// one 代表第一个参数 +type para1710 struct { + boxTypes [][]int + truckSize int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1710 struct { + one int +} + +func Test_Problem1710(t *testing.T) { + + qs := []question1710{ + + { + para1710{[][]int{{1, 3}, {2, 2}, {3, 1}}, 4}, + ans1710{8}, + }, + + { + para1710{[][]int{{5, 10}, {2, 5}, {4, 7}, {3, 9}}, 10}, + ans1710{91}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1710------------------------\n") + + for _, q := range qs { + _, p := q.ans1710, q.para1710 + fmt.Printf("【input】:%v 【output】:%v\n", p, maximumUnits(p.boxTypes, p.truckSize)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1710.Maximum-Units-on-a-Truck/README.md b/leetcode/1710.Maximum-Units-on-a-Truck/README.md new file mode 100644 index 000000000..f6ab86363 --- /dev/null +++ b/leetcode/1710.Maximum-Units-on-a-Truck/README.md @@ -0,0 +1,77 @@ +# [1710. Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck/) + + +## 题目 + +You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: + +- `numberOfBoxesi` is the number of boxes of type `i`. +- `numberOfUnitsPerBoxi`is the number of units in each box of the type `i`. + +You are also given an integer `truckSize`, which is the **maximum** number of **boxes** that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed `truckSize`. + +Return *the **maximum** total number of **units** that can be put on the truck.* + +**Example 1:** + +``` +Input: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4 +Output: 8 +Explanation: There are: +- 1 box of the first type that contains 3 units. +- 2 boxes of the second type that contain 2 units each. +- 3 boxes of the third type that contain 1 unit each. +You can take all the boxes of the first and second types, and one box of the third type. +The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. +``` + +**Example 2:** + +``` +Input: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10 +Output: 91 +``` + +**Constraints:** + +- `1 <= boxTypes.length <= 1000` +- `1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000` +- `1 <= truckSize <= 106` + +## 题目大意 + +请你将一些箱子装在 一辆卡车 上。给你一个二维数组 boxTypes ,其中 boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi] : + +- numberOfBoxesi 是类型 i 的箱子的数量。- +- numberOfUnitsPerBoxi 是类型 i 每个箱子可以装载的单元数量。 + +整数 truckSize 表示卡车上可以装载 箱子 的 最大数量 。只要箱子数量不超过 truckSize ,你就可以选择任意箱子装到卡车上。返回卡车可以装载 单元 的 最大 总数。 + +## 解题思路 + +- 简单题。先将箱子按照单元数量从大到小排序。要想卡车装载单元数最大,那么需要尽量装单元数多的箱子。所以排序以后从单元数量多的箱子开始取。一直取至 truckSize 没有空间。累积的单元数即最大总数。 + +## 代码 + +```go +package leetcode + +import "sort" + +func maximumUnits(boxTypes [][]int, truckSize int) int { + sort.Slice(boxTypes, func(i, j int) bool { + return boxTypes[i][1] > boxTypes[j][1] + }) + res := 0 + for i := 0; truckSize > 0 && i < len(boxTypes); i++ { + if truckSize >= boxTypes[i][0] { + truckSize -= boxTypes[i][0] + res += (boxTypes[i][1] * boxTypes[i][0]) + } else { + res += (truckSize * boxTypes[i][1]) + truckSize = 0 + } + } + return res +} +``` \ No newline at end of file diff --git a/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank.go b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank.go new file mode 100644 index 000000000..20e62732a --- /dev/null +++ b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank.go @@ -0,0 +1,13 @@ +package leetcode + +func totalMoney(n int) int { + res := 0 + for tmp, count := 1, 7; n > 0; tmp, count = tmp+1, 7 { + for m := tmp; n > 0 && count > 0; m++ { + res += m + n-- + count-- + } + } + return res +} diff --git a/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank_test.go b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank_test.go new file mode 100644 index 000000000..e6c47c29c --- /dev/null +++ b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/1716. Calculate Money in Leetcode Bank_test.go @@ -0,0 +1,52 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1716 struct { + para1716 + ans1716 +} + +// para 是参数 +// one 代表第一个参数 +type para1716 struct { + n int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1716 struct { + one int +} + +func Test_Problem1716(t *testing.T) { + + qs := []question1716{ + + { + para1716{4}, + ans1716{10}, + }, + + { + para1716{10}, + ans1716{37}, + }, + + { + para1716{20}, + ans1716{96}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1716------------------------\n") + + for _, q := range qs { + _, p := q.ans1716, q.para1716 + fmt.Printf("【input】:%v 【output】:%v\n", p, totalMoney(p.n)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1716.Calculate-Money-in-Leetcode-Bank/README.md b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/README.md new file mode 100644 index 000000000..34eb627db --- /dev/null +++ b/leetcode/1716.Calculate-Money-in-Leetcode-Bank/README.md @@ -0,0 +1,64 @@ +# [1716. Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank/) + + +## 题目 + +Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. + +He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. + +Given `n`, return *the total amount of money he will have in the Leetcode bank at the end of the* `nth` *day.* + +**Example 1:** + +``` +Input: n = 4 +Output: 10 +Explanation: After the 4th day, the total is 1 + 2 + 3 + 4 = 10. +``` + +**Example 2:** + +``` +Input: n = 10 +Output: 37 +Explanation: After the 10th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2nd Monday, Hercy only puts in $2. +``` + +**Example 3:** + +``` +Input: n = 20 +Output: 96 +Explanation: After the 20th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96. +``` + +**Constraints:** + +- `1 <= n <= 1000` + +## 题目大意 + +Hercy 想要为购买第一辆车存钱。他 每天 都往力扣银行里存钱。最开始,他在周一的时候存入 1 块钱。从周二到周日,他每天都比前一天多存入 1 块钱。在接下来每一个周一,他都会比 前一个周一 多存入 1 块钱。给你 n ,请你返回在第 n 天结束的时候他在力扣银行总共存了多少块钱。 + +## 解题思路 + +- 简单题。按照题意写 2 层循环即可。 + +## 代码 + +```go +package leetcode + +func totalMoney(n int) int { + res := 0 + for tmp, count := 1, 7; n > 0; tmp, count = tmp+1, 7 { + for m := tmp; n > 0 && count > 0; m++ { + res += m + n-- + count-- + } + } + return res +} +``` \ No newline at end of file diff --git a/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array.go b/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array.go new file mode 100644 index 000000000..108624cbc --- /dev/null +++ b/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array.go @@ -0,0 +1,10 @@ +package leetcode + +func decode(encoded []int, first int) []int { + arr := make([]int, len(encoded)+1) + arr[0] = first + for i, val := range encoded { + arr[i+1] = arr[i] ^ val + } + return arr +} diff --git a/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array_test.go b/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array_test.go new file mode 100644 index 000000000..2b152ecc2 --- /dev/null +++ b/leetcode/1720.Decode-XORed-Array/1720. Decode XORed Array_test.go @@ -0,0 +1,48 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1720 struct { + para1720 + ans1720 +} + +// para 是参数 +// one 代表第一个参数 +type para1720 struct { + encoded []int + first int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1720 struct { + one []int +} + +func Test_Problem1720(t *testing.T) { + + qs := []question1720{ + + { + para1720{[]int{1, 2, 3}, 1}, + ans1720{[]int{1, 0, 2, 1}}, + }, + + { + para1720{[]int{6, 2, 7, 3}, 4}, + ans1720{[]int{4, 2, 0, 7, 4}}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1720------------------------\n") + + for _, q := range qs { + _, p := q.ans1720, q.para1720 + fmt.Printf("【input】:%v 【output】:%v\n", p, decode(p.encoded, p.first)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1720.Decode-XORed-Array/README.md b/leetcode/1720.Decode-XORed-Array/README.md new file mode 100644 index 000000000..9cff1dcc8 --- /dev/null +++ b/leetcode/1720.Decode-XORed-Array/README.md @@ -0,0 +1,59 @@ +# [1720. Decode XORed Array](https://leetcode.com/problems/decode-xored-array/) + + +## 题目 + +There is a **hidden** integer array `arr` that consists of `n` non-negative integers. + +It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`. + +You are given the `encoded` array. You are also given an integer `first`, that is the first element of `arr`, i.e. `arr[0]`. + +Return *the original array* `arr`. It can be proved that the answer exists and is unique. + +**Example 1:** + +``` +Input: encoded = [1,2,3], first = 1 +Output: [1,0,2,1] +Explanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3] + +``` + +**Example 2:** + +``` +Input: encoded = [6,2,7,3], first = 4 +Output: [4,2,0,7,4] + +``` + +**Constraints:** + +- `2 <= n <= 104` +- `encoded.length == n - 1` +- `0 <= encoded[i] <= 105` +- `0 <= first <= 10^5` + +## 题目大意 + +未知 整数数组 arr 由 n 个非负整数组成。经编码后变为长度为 n - 1 的另一个整数数组 encoded ,其中 encoded[i] = arr[i] XOR arr[i + 1] 。例如,arr = [1,0,2,1] 经编码后得到 encoded = [1,2,3] 。给你编码后的数组 encoded 和原数组 arr 的第一个元素 first(arr[0])。请解码返回原数组 arr 。可以证明答案存在并且是唯一的。 + +## 解题思路 + +- 简单题。按照题意,求返回解码以后的原数组,即将编码后的数组前后两两元素依次做异或 `XOR` 运算。 + +## 代码 + +```go +package leetcode + +func decode(encoded []int, first int) []int { + arr := make([]int, len(encoded)+1) + arr[0] = first + for i, val := range encoded { + arr[i+1] = arr[i] ^ val + } + return arr +} +``` \ No newline at end of file diff --git a/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square.go b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square.go new file mode 100644 index 000000000..eec17bfb8 --- /dev/null +++ b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square.go @@ -0,0 +1,20 @@ +package leetcode + +func countGoodRectangles(rectangles [][]int) int { + minLength, count := 0, 0 + for i, _ := range rectangles { + minSide := 0 + if rectangles[i][0] <= rectangles[i][1] { + minSide = rectangles[i][0] + } else { + minSide = rectangles[i][1] + } + if minSide > minLength { + minLength = minSide + count = 1 + } else if minSide == minLength { + count++ + } + } + return count +} diff --git a/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square_test.go b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square_test.go new file mode 100644 index 000000000..40b7d86e9 --- /dev/null +++ b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/1725. Number Of Rectangles That Can Form The Largest Square_test.go @@ -0,0 +1,47 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1725 struct { + para1725 + ans1725 +} + +// para 是参数 +// one 代表第一个参数 +type para1725 struct { + rectangles [][]int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1725 struct { + one int +} + +func Test_Problem1725(t *testing.T) { + + qs := []question1725{ + + { + para1725{[][]int{{5, 8}, {3, 9}, {5, 12}, {16, 5}}}, + ans1725{3}, + }, + + { + para1725{[][]int{{2, 3}, {3, 7}, {4, 3}, {3, 7}}}, + ans1725{3}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1725------------------------\n") + + for _, q := range qs { + _, p := q.ans1725, q.para1725 + fmt.Printf("【input】:%v 【output】:%v\n", p, countGoodRectangles(p.rectangles)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/README.md b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/README.md new file mode 100644 index 000000000..0c59194fa --- /dev/null +++ b/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square/README.md @@ -0,0 +1,68 @@ +# [1725. Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/) + + +## 题目 + +You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`. + +You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square with a side length of at most `4`. + +Let `maxLen` be the side length of the **largest** square you can obtain from any of the given rectangles. + +Return *the **number** of rectangles that can make a square with a side length of* `maxLen`. + +**Example 1:** + +``` +Input: rectangles = [[5,8],[3,9],[5,12],[16,5]] +Output: 3 +Explanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5]. +The largest possible square is of length 5, and you can get it out of 3 rectangles. +``` + +**Example 2:** + +``` +Input: rectangles = [[2,3],[3,7],[4,3],[3,7]] +Output: 3 +``` + +**Constraints:** + +- `1 <= rectangles.length <= 1000` +- `rectangles[i].length == 2` +- `1 <= li, wi <= 10^9` +- `li != wi` + +## 题目大意 + +给你一个数组 rectangles ,其中 rectangles[i] = [li, wi] 表示第 i 个矩形的长度为 li 、宽度为 wi 。如果存在 k 同时满足 k <= li 和 k <= wi ,就可以将第 i 个矩形切成边长为 k 的正方形。例如,矩形 [4,6] 可以切成边长最大为 4 的正方形。设 maxLen 为可以从矩形数组 rectangles 切分得到的 最大正方形 的边长。返回可以切出边长为 maxLen 的正方形的矩形 数目 。 + +## 解题思路 + +- 简单题。扫描数组中的每一个矩形,先找到边长较小的那条边,作为正方形的边长。扫描过程中动态更新最大的正方形边长,并累加计数。循环一遍结束,输出最终计数值即可。 + +## 代码 + +```go +package leetcode + +func countGoodRectangles(rectangles [][]int) int { + minLength, count := 0, 0 + for i, _ := range rectangles { + minSide := 0 + if rectangles[i][0] <= rectangles[i][1] { + minSide = rectangles[i][0] + } else { + minSide = rectangles[i][1] + } + if minSide > minLength { + minLength = minSide + count = 1 + } else if minSide == minLength { + count++ + } + } + return count +} +``` \ No newline at end of file diff --git a/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude.go b/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude.go new file mode 100644 index 000000000..62d66bf6d --- /dev/null +++ b/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude.go @@ -0,0 +1,12 @@ +package leetcode + +func largestAltitude(gain []int) int { + max, height := 0, 0 + for _, g := range gain { + height += g + if height > max { + max = height + } + } + return max +} diff --git a/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude_test.go b/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude_test.go new file mode 100644 index 000000000..eb56bfe0f --- /dev/null +++ b/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude_test.go @@ -0,0 +1,47 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1732 struct { + para1732 + ans1732 +} + +// para 是参数 +// one 代表第一个参数 +type para1732 struct { + gain []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1732 struct { + one int +} + +func Test_Problem1732(t *testing.T) { + + qs := []question1732{ + + { + para1732{[]int{-5, 1, 5, 0, -7}}, + ans1732{1}, + }, + + { + para1732{[]int{-4, -3, -2, -1, 4, 3, 2}}, + ans1732{0}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1732------------------------\n") + + for _, q := range qs { + _, p := q.ans1732, q.para1732 + fmt.Printf("【input】:%v 【output】:%v\n", p, largestAltitude(p.gain)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1732.Find-the-Highest-Altitude/README.md b/leetcode/1732.Find-the-Highest-Altitude/README.md new file mode 100644 index 000000000..5b6b437d8 --- /dev/null +++ b/leetcode/1732.Find-the-Highest-Altitude/README.md @@ -0,0 +1,55 @@ +# [1732. Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude/) + + +## 题目 + +There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. + +You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i` and `i + 1` for all (`0 <= i < n)`. Return *the **highest altitude** of a point.* + +**Example 1:** + +``` +Input: gain = [-5,1,5,0,-7] +Output: 1 +Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1. +``` + +**Example 2:** + +``` +Input: gain = [-4,-3,-2,-1,4,3,2] +Output: 0 +Explanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0. +``` + +**Constraints:** + +- `n == gain.length` +- `1 <= n <= 100` +- `100 <= gain[i] <= 100` + +## 题目大意 + +有一个自行车手打算进行一场公路骑行,这条路线总共由 n + 1 个不同海拔的点组成。自行车手从海拔为 0 的点 0 开始骑行。给你一个长度为 n 的整数数组 gain ,其中 gain[i] 是点 i 和点 i + 1 的 净海拔高度差(0 <= i < n)。请你返回 最高点的海拔 。 + +## 解题思路 + +- 简单题。循环数组依次从第一个海拔点开始还原每个海拔点,动态记录最大高度。循环结束输出最大高度即可。 + +## 代码 + +```go +package leetcode + +func largestAltitude(gain []int) int { + max, height := 0, 0 + for _, g := range gain { + height += g + if height > max { + max = height + } + } + return max +} +``` \ No newline at end of file diff --git a/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits.go b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits.go new file mode 100644 index 000000000..7b30b387c --- /dev/null +++ b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits.go @@ -0,0 +1,25 @@ +package leetcode + +func maximumTime(time string) string { + timeb := []byte(time) + if timeb[3] == '?' { + timeb[3] = '5' + } + if timeb[4] == '?' { + timeb[4] = '9' + } + if timeb[0] == '?' { + if int(timeb[1]-'0') > 3 && int(timeb[1]-'0') < 10 { + timeb[0] = '1' + } else { + timeb[0] = '2' + } + } + if timeb[1] == '?' { + timeb[1] = '9' + } + if timeb[0] == '2' && timeb[1] == '9' { + timeb[1] = '3' + } + return string(timeb) +} diff --git a/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits_test.go b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits_test.go new file mode 100644 index 000000000..2213b85f1 --- /dev/null +++ b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/1736. Latest Time by Replacing Hidden Digits_test.go @@ -0,0 +1,52 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1736 struct { + para1736 + ans1736 +} + +// para 是参数 +// one 代表第一个参数 +type para1736 struct { + time string +} + +// ans 是答案 +// one 代表第一个答案 +type ans1736 struct { + one string +} + +func Test_Problem1736(t *testing.T) { + + qs := []question1736{ + + { + para1736{"2?:?0"}, + ans1736{"23:50"}, + }, + + { + para1736{"0?:3?"}, + ans1736{"09:39"}, + }, + + { + para1736{"1?:22"}, + ans1736{"19:22"}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1736------------------------\n") + + for _, q := range qs { + _, p := q.ans1736, q.para1736 + fmt.Printf("【input】:%v 【output】:%v\n", p, maximumTime(p.time)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/README.md b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/README.md new file mode 100644 index 000000000..a34ceb176 --- /dev/null +++ b/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits/README.md @@ -0,0 +1,75 @@ +# [1736. Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/) + + +## 题目 + +You are given a string `time` in the form of `hh:mm`, where some of the digits in the string are hidden (represented by `?`). + +The valid times are those inclusively between `00:00` and `23:59`. + +Return *the latest valid time you can get from* `time` *by replacing the hidden* *digits*. + +**Example 1:** + +``` +Input: time = "2?:?0" +Output: "23:50" +Explanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50. +``` + +**Example 2:** + +``` +Input: time = "0?:3?" +Output: "09:39" +``` + +**Example 3:** + +``` +Input: time = "1?:22" +Output: "19:22" +``` + +**Constraints:** + +- `time` is in the format `hh:mm`. +- It is guaranteed that you can produce a valid time from the given string. + +## 题目大意 + +给你一个字符串 time ,格式为 hh:mm(小时:分钟),其中某几位数字被隐藏(用 ? 表示)。有效的时间为 00:00 到 23:59 之间的所有时间,包括 00:00 和 23:59 。替换 time 中隐藏的数字,返回你可以得到的最晚有效时间。 + +## 解题思路 + +- 简单题。根据题意,需要找到最晚的有效时间。枚举时间 4 个位置即可。如果第 3 个位置是 ?,那么它最晚时间是 5;如果第 4 个位置是 ?,那么它最晚时间是 9;如果第 2 个位置是 ?,那么它最晚时间是 9;如果第 1 个位置是 ?,根据第 2 个位置判断,如果第 2 个位置是大于 3 的数,那么第一个位置最晚时间是 1,如果第 2 个位置是小于 3 的数那么第一个位置最晚时间是 2 。按照上述规则即可还原最晚时间。 + +## 代码 + +```go +package leetcode + +func maximumTime(time string) string { + timeb := []byte(time) + if timeb[3] == '?' { + timeb[3] = '5' + } + if timeb[4] == '?' { + timeb[4] = '9' + } + if timeb[0] == '?' { + if int(timeb[1]-'0') > 3 && int(timeb[1]-'0') < 10 { + timeb[0] = '1' + } else { + timeb[0] = '2' + } + } + if timeb[1] == '?' { + timeb[1] = '9' + } + if timeb[0] == '2' && timeb[1] == '9' { + timeb[1] = '3' + } + return string(timeb) +} +``` \ No newline at end of file diff --git a/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box.go b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box.go new file mode 100644 index 000000000..e4d415872 --- /dev/null +++ b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box.go @@ -0,0 +1,17 @@ +package leetcode + +func countBalls(lowLimit int, highLimit int) int { + buckets, maxBall := [46]int{}, 0 + for i := lowLimit; i <= highLimit; i++ { + t := 0 + for j := i; j > 0; { + t += j % 10 + j = j / 10 + } + buckets[t]++ + if buckets[t] > maxBall { + maxBall = buckets[t] + } + } + return maxBall +} diff --git a/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box_test.go b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box_test.go new file mode 100644 index 000000000..06bc63a1e --- /dev/null +++ b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/1742. Maximum Number of Balls in a Box_test.go @@ -0,0 +1,53 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1742 struct { + para1742 + ans1742 +} + +// para 是参数 +// one 代表第一个参数 +type para1742 struct { + lowLimit int + highLimit int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1742 struct { + one int +} + +func Test_Problem1742(t *testing.T) { + + qs := []question1742{ + + { + para1742{1, 10}, + ans1742{2}, + }, + + { + para1742{5, 15}, + ans1742{2}, + }, + + { + para1742{19, 28}, + ans1742{2}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1742------------------------\n") + + for _, q := range qs { + _, p := q.ans1742, q.para1742 + fmt.Printf("【input】:%v 【output】:%v\n", p, countBalls(p.lowLimit, p.highLimit)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/README.md b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/README.md new file mode 100644 index 000000000..5c5284b61 --- /dev/null +++ b/leetcode/1742.Maximum-Number-of-Balls-in-a-Box/README.md @@ -0,0 +1,81 @@ +# [1742. Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box/) + + +## 题目 + +You are working in a ball factory where you have `n` balls numbered from `lowLimit` up to `highLimit` **inclusive** (i.e., `n == highLimit - lowLimit + 1`), and an infinite number of boxes numbered from `1` to `infinity`. + +Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number `321` will be put in the box number `3 + 2 + 1 = 6` and the ball number `10` will be put in the box number `1 + 0 = 1`. + +Given two integers `lowLimit` and `highLimit`, return *the number of balls in the box with the most balls.* + +**Example 1:** + +``` +Input: lowLimit = 1, highLimit = 10 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 ... +Ball Count: 2 1 1 1 1 1 1 1 1 0 0 ... +Box 1 has the most number of balls with 2 balls. +``` + +**Example 2:** + +``` +Input: lowLimit = 5, highLimit = 15 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 ... +Ball Count: 1 1 1 1 2 2 1 1 1 0 0 ... +Boxes 5 and 6 have the most number of balls with 2 balls in each. + +``` + +**Example 3:** + +``` +Input: lowLimit = 19, highLimit = 28 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 12 ... +Ball Count: 0 1 1 1 1 1 1 1 1 2 0 0 ... +Box 10 has the most number of balls with 2 balls. + +``` + +**Constraints:** + +- `1 <= lowLimit <= highLimit <= 10^5` + +## 题目大意 + +你在一家生产小球的玩具厂工作,有 n 个小球,编号从 lowLimit 开始,到 highLimit 结束(包括 lowLimit 和 highLimit ,即 n == highLimit - lowLimit + 1)。另有无限数量的盒子,编号从 1 到 infinity 。你的工作是将每个小球放入盒子中,其中盒子的编号应当等于小球编号上每位数字的和。例如,编号 321 的小球应当放入编号 3 + 2 + 1 = 6 的盒子,而编号 10 的小球应当放入编号 1 + 0 = 1 的盒子。 + +给你两个整数 lowLimit 和 highLimit ,返回放有最多小球的盒子中的小球数量。如果有多个盒子都满足放有最多小球,只需返回其中任一盒子的小球数量。 + +## 解题思路 + +- 简单题。循环遍历一遍数组,依次计算出所有小球的编号各位数字累加和,并且动态维护放有小球最多的数目。循环结束,输出最多小球个数即可。 + +## 代码 + +```go +package leetcode + +func countBalls(lowLimit int, highLimit int) int { + buckets, maxBall := [46]int{}, 0 + for i := lowLimit; i <= highLimit; i++ { + t := 0 + for j := i; j > 0; { + t += j % 10 + j = j / 10 + } + buckets[t]++ + if buckets[t] > maxBall { + maxBall = buckets[t] + } + } + return maxBall +} +``` \ No newline at end of file diff --git a/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements.go b/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements.go new file mode 100644 index 000000000..e8ebac9af --- /dev/null +++ b/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements.go @@ -0,0 +1,17 @@ +package leetcode + +func sumOfUnique(nums []int) int { + freq, res := make(map[int]int), 0 + for _, v := range nums { + if _, ok := freq[v]; !ok { + freq[v] = 0 + } + freq[v]++ + } + for k, v := range freq { + if v == 1 { + res += k + } + } + return res +} diff --git a/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements_test.go b/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements_test.go new file mode 100644 index 000000000..0a38e0b45 --- /dev/null +++ b/leetcode/1748.Sum-of-Unique-Elements/1748. Sum of Unique Elements_test.go @@ -0,0 +1,52 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1748 struct { + para1748 + ans1748 +} + +// para 是参数 +// one 代表第一个参数 +type para1748 struct { + nums []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1748 struct { + one int +} + +func Test_Problem1748(t *testing.T) { + + qs := []question1748{ + + { + para1748{[]int{1, 2, 3, 2}}, + ans1748{4}, + }, + + { + para1748{[]int{1, 1, 1, 1, 1}}, + ans1748{0}, + }, + + { + para1748{[]int{1, 2, 3, 4, 5}}, + ans1748{15}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1748------------------------\n") + + for _, q := range qs { + _, p := q.ans1748, q.para1748 + fmt.Printf("【input】:%v 【output】:%v\n", p, sumOfUnique(p.nums)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1748.Sum-of-Unique-Elements/README.md b/leetcode/1748.Sum-of-Unique-Elements/README.md new file mode 100644 index 000000000..6a3ac8b27 --- /dev/null +++ b/leetcode/1748.Sum-of-Unique-Elements/README.md @@ -0,0 +1,67 @@ +# [1748. Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements/) + + +## 题目 + +You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. + +Return *the **sum** of all the unique elements of* `nums`. + +**Example 1:** + +``` +Input: nums = [1,2,3,2] +Output: 4 +Explanation: The unique elements are [1,3], and the sum is 4. +``` + +**Example 2:** + +``` +Input: nums = [1,1,1,1,1] +Output: 0 +Explanation: There are no unique elements, and the sum is 0. +``` + +**Example 3:** + +``` +Input: nums = [1,2,3,4,5] +Output: 15 +Explanation: The unique elements are [1,2,3,4,5], and the sum is 15. +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `1 <= nums[i] <= 100` + +## 题目大意 + +给你一个整数数组 `nums` 。数组中唯一元素是那些只出现 **恰好一次** 的元素。请你返回 `nums` 中唯一元素的 **和** 。 + +## 解题思路 + +- 简单题。利用 map 统计出每个元素出现的频次。再累加所有频次为 1 的元素,最后输出累加和即可。 + +## 代码 + +```go +package leetcode + +func sumOfUnique(nums []int) int { + freq, res := make(map[int]int), 0 + for _, v := range nums { + if _, ok := freq[v]; !ok { + freq[v] = 0 + } + freq[v]++ + } + for k, v := range freq { + if v == 1 { + res += k + } + } + return res +} +``` \ No newline at end of file diff --git a/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated.go b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated.go new file mode 100644 index 000000000..ef10f2d95 --- /dev/null +++ b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated.go @@ -0,0 +1,14 @@ +package leetcode + +func check(nums []int) bool { + count := 0 + for i := 0; i < len(nums)-1; i++ { + if nums[i] > nums[i+1] { + count++ + if count > 1 || nums[0] < nums[len(nums)-1] { + return false + } + } + } + return true +} diff --git a/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated_test.go b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated_test.go new file mode 100644 index 000000000..4ebdd4e01 --- /dev/null +++ b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/1752. Check if Array Is Sorted and Rotated_test.go @@ -0,0 +1,67 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1752 struct { + para1752 + ans1752 +} + +// para 是参数 +// one 代表第一个参数 +type para1752 struct { + nums []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans1752 struct { + one bool +} + +func Test_Problem1752(t *testing.T) { + + qs := []question1752{ + + { + para1752{[]int{3, 4, 5, 1, 2}}, + ans1752{true}, + }, + + { + para1752{[]int{2, 1, 3, 4}}, + ans1752{false}, + }, + + { + para1752{[]int{1, 2, 3}}, + ans1752{true}, + }, + + { + para1752{[]int{1, 1, 1}}, + ans1752{true}, + }, + + { + para1752{[]int{2, 1}}, + ans1752{true}, + }, + + { + para1752{[]int{1, 3, 2, 4}}, + ans1752{false}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1752------------------------\n") + + for _, q := range qs { + _, p := q.ans1752, q.para1752 + fmt.Printf("【input】:%v 【output】:%v\n", p, check(p.nums)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/README.md b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/README.md new file mode 100644 index 000000000..775b7c192 --- /dev/null +++ b/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated/README.md @@ -0,0 +1,86 @@ +# [1752. Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/) + + +## 题目 + +Given an array `nums`, return `true` *if the array was originally sorted in non-decreasing order, then rotated **some** number of positions (including zero)*. Otherwise, return `false`. + +There may be **duplicates** in the original array. + +**Note:** An array `A` rotated by `x` positions results in an array `B` of the same length such that `A[i] == B[(i+x) % A.length]`, where `%` is the modulo operation. + +**Example 1:** + +``` +Input: nums = [3,4,5,1,2] +Output: true +Explanation: [1,2,3,4,5] is the original sorted array. +You can rotate the array by x = 3 positions to begin on the the element of value 3: [3,4,5,1,2]. +``` + +**Example 2:** + +``` +Input: nums = [2,1,3,4] +Output: false +Explanation: There is no sorted array once rotated that can make nums. +``` + +**Example 3:** + +``` +Input: nums = [1,2,3] +Output: true +Explanation: [1,2,3] is the original sorted array. +You can rotate the array by x = 0 positions (i.e. no rotation) to make nums. +``` + +**Example 4:** + +``` +Input: nums = [1,1,1] +Output: true +Explanation: [1,1,1] is the original sorted array. +You can rotate any number of positions to make nums. +``` + +**Example 5:** + +``` +Input: nums = [2,1] +Output: true +Explanation: [1,2] is the original sorted array. +You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1]. +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `1 <= nums[i] <= 100` + +## 题目大意 + +给你一个数组 nums 。nums 的源数组中,所有元素与 nums 相同,但按非递减顺序排列。如果 nums 能够由源数组轮转若干位置(包括 0 个位置)得到,则返回 true ;否则,返回 false 。源数组中可能存在 重复项 。 + +## 解题思路 + +- 简单题。从头扫描一遍数组,找出相邻两个元素递减的数对。如果递减的数对只有 1 个,则有可能是轮转得来的,超过 1 个,则返回 false。题干里面还提到可能有多个重复元素,针对这一情况还需要判断一下 `nums[0]` 和 `nums[len(nums)-1]` 。如果是相同元素,`nums[0] < nums[len(nums)-1]`,并且数组中间还存在一对递减的数对,这时候也是 false。判断好上述这 2 种情况,本题得解。 + +## 代码 + +```go +package leetcode + +func check(nums []int) bool { + count := 0 + for i := 0; i < len(nums)-1; i++ { + if nums[i] > nums[i+1] { + count++ + if count > 1 || nums[0] < nums[len(nums)-1] { + return false + } + } + } + return true +} +``` \ No newline at end of file diff --git a/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String.go b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String.go new file mode 100644 index 000000000..ed0dabf5f --- /dev/null +++ b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String.go @@ -0,0 +1,18 @@ +package leetcode + +func minOperations(s string) int { + res := 0 + for i := 0; i < len(s); i++ { + if int(s[i]-'0') != i%2 { + res++ + } + } + return min(res, len(s)-res) +} + +func min(a, b int) int { + if a > b { + return b + } + return a +} diff --git a/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String_test.go b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String_test.go new file mode 100644 index 000000000..121db556a --- /dev/null +++ b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/1758. Minimum Changes To Make Alternating Binary String_test.go @@ -0,0 +1,52 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question1758 struct { + para1758 + ans1758 +} + +// para 是参数 +// one 代表第一个参数 +type para1758 struct { + s string +} + +// ans 是答案 +// one 代表第一个答案 +type ans1758 struct { + one int +} + +func Test_Problem1758(t *testing.T) { + + qs := []question1758{ + + { + para1758{"0100"}, + ans1758{1}, + }, + + { + para1758{"10"}, + ans1758{0}, + }, + + { + para1758{"1111"}, + ans1758{2}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 1758------------------------\n") + + for _, q := range qs { + _, p := q.ans1758, q.para1758 + fmt.Printf("【input】:%v 【output】:%v\n", p, minOperations(p.s)) + } + fmt.Printf("\n\n\n") +} diff --git a/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/README.md b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/README.md new file mode 100644 index 000000000..f268462ee --- /dev/null +++ b/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String/README.md @@ -0,0 +1,70 @@ +# [1758. Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string/) + + +## 题目 + +You are given a string `s` consisting only of the characters `'0'` and `'1'`. In one operation, you can change any `'0'` to `'1'` or vice versa. + +The string is called alternating if no two adjacent characters are equal. For example, the string `"010"` is alternating, while the string `"0100"` is not. + +Return *the **minimum** number of operations needed to make* `s` *alternating*. + +**Example 1:** + +``` +Input: s = "0100" +Output: 1 +Explanation: If you change the last character to '1', s will be "0101", which is alternating. +``` + +**Example 2:** + +``` +Input: s = "10" +Output: 0 +Explanation: s is already alternating. +``` + +**Example 3:** + +``` +Input: s = "1111" +Output: 2 +Explanation: You need two operations to reach "0101" or "1010". +``` + +**Constraints:** + +- `1 <= s.length <= 104` +- `s[i]` is either `'0'` or `'1'`. + +## 题目大意 + +你将得到一个仅包含字符“ 0”和“ 1”的字符串 `s`。 在一项操作中,你可以将任何 `'0'` 更改为 `'1'`,反之亦然。 如果两个相邻字符都不相等,则该字符串称为交替字符串。 例如,字符串“ 010”是交替的,而字符串“ 0100”则不是。 返回使 `s` 交替所需的最小操作数。 + +## 解题思路 + +- 简单题。利用数组下标奇偶交替性来判断交替字符串。交替字符串有 2 种,一个是 `'01010101……'` 还有一个是 `'1010101010……'`,这两个只需要计算出一个即可,另外一个利用 `len(s) - res` 就是答案。 + +## 代码 + +```go +package leetcode + +func minOperations(s string) int { + res := 0 + for i := 0; i < len(s); i++ { + if int(s[i]-'0') != i%2 { + res++ + } + } + return min(res, len(s)-res) +} + +func min(a, b int) int { + if a > b { + return b + } + return a +} +``` \ No newline at end of file diff --git a/website/content/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable.md b/website/content/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable.md index 7179ea6b6..594743b73 100644 --- a/website/content/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable.md +++ b/website/content/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable.md @@ -106,5 +106,5 @@ func maxNumEdgesToRemove(n int, edges [][]int) int { ----------------------------------------------
diff --git a/website/content/ChapterFour/1600~1699/1603.Design-Parking-System.md b/website/content/ChapterFour/1600~1699/1603.Design-Parking-System.md new file mode 100644 index 000000000..8cbb81739 --- /dev/null +++ b/website/content/ChapterFour/1600~1699/1603.Design-Parking-System.md @@ -0,0 +1,110 @@ +# [1603. Design Parking System](https://leetcode.com/problems/design-parking-system/) + + +## 题目 + +Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. + +Implement the `ParkingSystem` class: + +- `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slots for each parking space are given as part of the constructor. +- `bool addCar(int carType)` Checks whether there is a parking space of `carType` for the car that wants to get into the parking lot. `carType` can be of three kinds: big, medium, or small, which are represented by `1`, `2`, and `3` respectively. **A car can only park in a parking space of its** `carType`. If there is no space available, return `false`, else park the car in that size space and return `true`. + +**Example 1:** + +``` +Input +["ParkingSystem", "addCar", "addCar", "addCar", "addCar"] +[[1, 1, 0], [1], [2], [3], [1]] +Output +[null, true, true, false, false] + +Explanation +ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0); +parkingSystem.addCar(1); // return true because there is 1 available slot for a big car +parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car +parkingSystem.addCar(3); // return false because there is no available slot for a small car +parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied. +``` + +**Constraints:** + +- `0 <= big, medium, small <= 1000` +- `carType` is `1`, `2`, or `3` +- At most `1000` calls will be made to `addCar` + +## 题目大意 + +请你给一个停车场设计一个停车系统。停车场总共有三种不同大小的车位:大,中和小,每种尺寸分别有固定数目的车位。 + +请你实现 ParkingSystem 类: + +- ParkingSystem(int big, int medium, int small) 初始化 ParkingSystem 类,三个参数分别对应每种停车位的数目。 +- bool addCar(int carType) 检查是否有 carType 对应的停车位。 carType 有三种类型:大,中,小,分别用数字 1, 2 和 3 表示。一辆车只能停在 carType 对应尺寸的停车位中。如果没有空车位,请返回 false ,否则将该车停入车位并返回 true 。 + +## 解题思路 + +- 简单题。分别用 3 个变量表示大,中和小车位。`addCar()` 判断这 3 个变量是否还有空车位即可。 + +## 代码 + +```go +package leetcode + +type ParkingSystem struct { + Big int + Medium int + Small int +} + +func Constructor(big int, medium int, small int) ParkingSystem { + return ParkingSystem{ + Big: big, + Medium: medium, + Small: small, + } +} + +func (this *ParkingSystem) AddCar(carType int) bool { + switch carType { + case 1: + { + if this.Big > 0 { + this.Big-- + return true + } + return false + } + case 2: + { + if this.Medium > 0 { + this.Medium-- + return true + } + return false + } + case 3: + { + if this.Small > 0 { + this.Small-- + return true + } + return false + } + } + return false +} + +/** + * Your ParkingSystem object will be instantiated and called as such: + * obj := Constructor(big, medium, small); + * param_1 := obj.AddCar(carType); + */ +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1600~1699/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X.md b/website/content/ChapterFour/1600~1699/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X.md new file mode 100644 index 000000000..ac9a93658 --- /dev/null +++ b/website/content/ChapterFour/1600~1699/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X.md @@ -0,0 +1,87 @@ +# [1608. Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/) + +## 题目 + +You are given an array `nums` of non-negative integers. `nums` is considered **special** if there exists a number `x` such that there are **exactly** `x` numbers in `nums` that are **greater than or equal to** `x`. + +Notice that `x` **does not** have to be an element in `nums`. + +Return `x` *if the array is **special**, otherwise, return* `-1`. It can be proven that if `nums` is special, the value for `x` is **unique**. + +**Example 1:** + +``` +Input: nums = [3,5] +Output: 2 +Explanation: There are 2 values (3 and 5) that are greater than or equal to 2. +``` + +**Example 2:** + +``` +Input: nums = [0,0] +Output: -1 +Explanation: No numbers fit the criteria for x. +If x = 0, there should be 0 numbers >= x, but there are 2. +If x = 1, there should be 1 number >= x, but there are 0. +If x = 2, there should be 2 numbers >= x, but there are 0. +x cannot be greater since there are only 2 numbers in nums. +``` + +**Example 3:** + +``` +Input: nums = [0,4,3,0,4] +Output: 3 +Explanation: There are 3 values that are greater than or equal to 3. +``` + +**Example 4:** + +``` +Input: nums = [3,6,7,7,0] +Output: -1 +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `0 <= nums[i] <= 1000` + +## 题目大意 + +给你一个非负整数数组 nums 。如果存在一个数 x ,使得 nums 中恰好有 x 个元素 大于或者等于 x ,那么就称 nums 是一个 特殊数组 ,而 x 是该数组的 特征值 。(注意: x 不必 是 nums 的中的元素。)如果数组 nums 是一个 特殊数组 ,请返回它的特征值 x 。否则,返回 -1 。可以证明的是,如果 nums 是特殊数组,那么其特征值 x 是 唯一的 。 + +## 解题思路 + +- 简单题。抓住题干中给的证明,特征值是唯一的。先将数组从小到大排序,下标的含义与特征值就等价了。下标 `i` 代表大于等于 `nums[i]` 的元素有 `len(nums) - i` 个,那么从第 0 个下标的元素开始遍历,如果这个元素都大于 `len(nums)`,那么后面 `len(nums)` 个元素也都大于等于它,特征值就找到了。如果特征值减一以后,仍然满足 `nums[i] >= x`,说明满足条件的值有多个,这一点不满足特征值唯一性,可以直接返回 -1 了。下标继续右移,特征值继续减一。如果最终循环结束依旧找不到特征值,返回 -1 。 + +## 代码 + +```go +package leetcode + +import "sort" + +func specialArray(nums []int) int { + sort.Ints(nums) + x := len(nums) + for _, num := range nums { + if num >= x { + return x + } + x-- + if num >= x { + return -1 + } + } + return -1 +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses.md b/website/content/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses.md index 7d3653962..4c24ceb5b 100644 --- a/website/content/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses.md +++ b/website/content/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses.md @@ -104,6 +104,6 @@ func max(a, b int) int { ---------------------------------------------- diff --git a/website/content/ChapterFour/1600~1699/1696.Jump-Game-VI.md b/website/content/ChapterFour/1600~1699/1696.Jump-Game-VI.md index 98ebfbf46..155af11ea 100644 --- a/website/content/ChapterFour/1600~1699/1696.Jump-Game-VI.md +++ b/website/content/ChapterFour/1600~1699/1696.Jump-Game-VI.md @@ -114,5 +114,5 @@ func max(a, b int) int { ---------------------------------------------- diff --git a/website/content/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md b/website/content/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md new file mode 100644 index 000000000..8ba364f7c --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md @@ -0,0 +1,86 @@ +# [1700. Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/) + + +## 题目 + +The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students stand in a queue. Each student either prefers square or circular sandwiches. + +The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a **stack**. At each step: + +- If the student at the front of the queue **prefers** the sandwich on the top of the stack, they will **take it** and leave the queue. +- Otherwise, they will **leave it** and go to the queue's end. + +This continues until none of the queue students want to take the top sandwich and are thus unable to eat. + +You are given two integer arrays `students` and `sandwiches` where `sandwiches[i]` is the type of the `ith` sandwich in the stack (`i = 0` is the top of the stack) and `students[j]` is the preference of the `jth` student in the initial queue (`j = 0` is the front of the queue). Return *the number of students that are unable to eat.* + +**Example 1:** + +``` +Input: students = [1,1,0,0], sandwiches = [0,1,0,1] +Output: 0 +Explanation: +- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1]. +- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0]. +- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1]. +- Front student leaves the top sandwich and returns to the end of the line making students = [0,1]. +- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1]. +- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = []. +Hence all students are able to eat. +``` + +**Example 2:** + +``` +Input: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1] +Output: 3 +``` + +**Constraints:** + +- `1 <= students.length, sandwiches.length <= 100` +- `students.length == sandwiches.length` +- `sandwiches[i]` is `0` or `1`. +- `students[i]` is `0` or `1`. + +## 题目大意 + +学校的自助午餐提供圆形和方形的三明治,分别用数字 0 和 1 表示。所有学生站在一个队列里,每个学生要么喜欢圆形的要么喜欢方形的。 +餐厅里三明治的数量与学生的数量相同。所有三明治都放在一个 栈 里,每一轮: + +- 如果队列最前面的学生 喜欢 栈顶的三明治,那么会 拿走它 并离开队列。 +- 否则,这名学生会 放弃这个三明治 并回到队列的尾部。 +这个过程会一直持续到队列里所有学生都不喜欢栈顶的三明治为止。 + +给你两个整数数组 students 和 sandwiches ,其中 sandwiches[i] 是栈里面第 i 个三明治的类型(i = 0 是栈的顶部), students[j] 是初始队列里第 j 名学生对三明治的喜好(j = 0 是队列的最开始位置)。请你返回无法吃午餐的学生数量。 + +## 解题思路 + +- 简单题。按照题意,学生不管怎么轮流领三明治,如果数量够,经过多轮循环,总能领到。问题可以等价为,学生依次到队列前面领取三明治。2 个种类的三明治都摆好放在那里了。最终领不到三明治的学生都是因为喜欢的三明治不够发放了。按照这个思路,先统计 2 种三明治的总个数,然后减去学生对三明治的需求总数,剩下的学生即都是无法满足的。 + +## 代码 + +```go +package leetcode + +func countStudents(students []int, sandwiches []int) int { + tmp, n, i := [2]int{}, len(students), 0 + for _, v := range students { + tmp[v]++ + } + for i < n && tmp[sandwiches[i]] > 0 { + tmp[sandwiches[i]]-- + i++ + } + return n - i +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md b/website/content/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md index 51204c9e7..7cd68e698 100644 --- a/website/content/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md +++ b/website/content/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md @@ -72,9 +72,10 @@ func numVowels(x string) int { } return res } -``` ---------------------------------------------- - - + diff --git a/website/content/ChapterFour/1700~1799/1710.Maximum-Units-on-a-Truck.md b/website/content/ChapterFour/1700~1799/1710.Maximum-Units-on-a-Truck.md new file mode 100644 index 000000000..8d7933546 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1710.Maximum-Units-on-a-Truck.md @@ -0,0 +1,84 @@ +# [1710. Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck/) + + +## 题目 + +You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`: + +- `numberOfBoxesi` is the number of boxes of type `i`. +- `numberOfUnitsPerBoxi`is the number of units in each box of the type `i`. + +You are also given an integer `truckSize`, which is the **maximum** number of **boxes** that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed `truckSize`. + +Return *the **maximum** total number of **units** that can be put on the truck.* + +**Example 1:** + +``` +Input: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4 +Output: 8 +Explanation: There are: +- 1 box of the first type that contains 3 units. +- 2 boxes of the second type that contain 2 units each. +- 3 boxes of the third type that contain 1 unit each. +You can take all the boxes of the first and second types, and one box of the third type. +The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. +``` + +**Example 2:** + +``` +Input: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10 +Output: 91 +``` + +**Constraints:** + +- `1 <= boxTypes.length <= 1000` +- `1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000` +- `1 <= truckSize <= 106` + +## 题目大意 + +请你将一些箱子装在 一辆卡车 上。给你一个二维数组 boxTypes ,其中 boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi] : + +- numberOfBoxesi 是类型 i 的箱子的数量。- +- numberOfUnitsPerBoxi 是类型 i 每个箱子可以装载的单元数量。 + +整数 truckSize 表示卡车上可以装载 箱子 的 最大数量 。只要箱子数量不超过 truckSize ,你就可以选择任意箱子装到卡车上。返回卡车可以装载 单元 的 最大 总数。 + +## 解题思路 + +- 简单题。先将箱子按照单元数量从大到小排序。要想卡车装载单元数最大,那么需要尽量装单元数多的箱子。所以排序以后从单元数量多的箱子开始取。一直取至 truckSize 没有空间。累积的单元数即最大总数。 + +## 代码 + +```go +package leetcode + +import "sort" + +func maximumUnits(boxTypes [][]int, truckSize int) int { + sort.Slice(boxTypes, func(i, j int) bool { + return boxTypes[i][1] > boxTypes[j][1] + }) + res := 0 + for i := 0; truckSize > 0 && i < len(boxTypes); i++ { + if truckSize >= boxTypes[i][0] { + truckSize -= boxTypes[i][0] + res += (boxTypes[i][1] * boxTypes[i][0]) + } else { + res += (truckSize * boxTypes[i][1]) + truckSize = 0 + } + } + return res +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1716.Calculate-Money-in-Leetcode-Bank.md b/website/content/ChapterFour/1700~1799/1716.Calculate-Money-in-Leetcode-Bank.md new file mode 100644 index 000000000..48256ac74 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1716.Calculate-Money-in-Leetcode-Bank.md @@ -0,0 +1,71 @@ +# [1716. Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank/) + + +## 题目 + +Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. + +He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. + +Given `n`, return *the total amount of money he will have in the Leetcode bank at the end of the* `nth` *day.* + +**Example 1:** + +``` +Input: n = 4 +Output: 10 +Explanation: After the 4th day, the total is 1 + 2 + 3 + 4 = 10. +``` + +**Example 2:** + +``` +Input: n = 10 +Output: 37 +Explanation: After the 10th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2nd Monday, Hercy only puts in $2. +``` + +**Example 3:** + +``` +Input: n = 20 +Output: 96 +Explanation: After the 20th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96. +``` + +**Constraints:** + +- `1 <= n <= 1000` + +## 题目大意 + +Hercy 想要为购买第一辆车存钱。他 每天 都往力扣银行里存钱。最开始,他在周一的时候存入 1 块钱。从周二到周日,他每天都比前一天多存入 1 块钱。在接下来每一个周一,他都会比 前一个周一 多存入 1 块钱。给你 n ,请你返回在第 n 天结束的时候他在力扣银行总共存了多少块钱。 + +## 解题思路 + +- 简单题。按照题意写 2 层循环即可。 + +## 代码 + +```go +package leetcode + +func totalMoney(n int) int { + res := 0 + for tmp, count := 1, 7; n > 0; tmp, count = tmp+1, 7 { + for m := tmp; n > 0 && count > 0; m++ { + res += m + n-- + count-- + } + } + return res +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1720.Decode-XORed-Array.md b/website/content/ChapterFour/1700~1799/1720.Decode-XORed-Array.md new file mode 100644 index 000000000..fb75c08c2 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1720.Decode-XORed-Array.md @@ -0,0 +1,66 @@ +# [1720. Decode XORed Array](https://leetcode.com/problems/decode-xored-array/) + + +## 题目 + +There is a **hidden** integer array `arr` that consists of `n` non-negative integers. + +It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`. + +You are given the `encoded` array. You are also given an integer `first`, that is the first element of `arr`, i.e. `arr[0]`. + +Return *the original array* `arr`. It can be proved that the answer exists and is unique. + +**Example 1:** + +``` +Input: encoded = [1,2,3], first = 1 +Output: [1,0,2,1] +Explanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3] + +``` + +**Example 2:** + +``` +Input: encoded = [6,2,7,3], first = 4 +Output: [4,2,0,7,4] + +``` + +**Constraints:** + +- `2 <= n <= 104` +- `encoded.length == n - 1` +- `0 <= encoded[i] <= 105` +- `0 <= first <= 10^5` + +## 题目大意 + +未知 整数数组 arr 由 n 个非负整数组成。经编码后变为长度为 n - 1 的另一个整数数组 encoded ,其中 encoded[i] = arr[i] XOR arr[i + 1] 。例如,arr = [1,0,2,1] 经编码后得到 encoded = [1,2,3] 。给你编码后的数组 encoded 和原数组 arr 的第一个元素 first(arr[0])。请解码返回原数组 arr 。可以证明答案存在并且是唯一的。 + +## 解题思路 + +- 简单题。按照题意,求返回解码以后的原数组,即将编码后的数组前后两两元素依次做异或 `XOR` 运算。 + +## 代码 + +```go +package leetcode + +func decode(encoded []int, first int) []int { + arr := make([]int, len(encoded)+1) + arr[0] = first + for i, val := range encoded { + arr[i+1] = arr[i] ^ val + } + return arr +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square.md b/website/content/ChapterFour/1700~1799/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square.md new file mode 100644 index 000000000..db322988d --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square.md @@ -0,0 +1,75 @@ +# [1725. Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/) + + +## 题目 + +You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`. + +You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square with a side length of at most `4`. + +Let `maxLen` be the side length of the **largest** square you can obtain from any of the given rectangles. + +Return *the **number** of rectangles that can make a square with a side length of* `maxLen`. + +**Example 1:** + +``` +Input: rectangles = [[5,8],[3,9],[5,12],[16,5]] +Output: 3 +Explanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5]. +The largest possible square is of length 5, and you can get it out of 3 rectangles. +``` + +**Example 2:** + +``` +Input: rectangles = [[2,3],[3,7],[4,3],[3,7]] +Output: 3 +``` + +**Constraints:** + +- `1 <= rectangles.length <= 1000` +- `rectangles[i].length == 2` +- `1 <= li, wi <= 10^9` +- `li != wi` + +## 题目大意 + +给你一个数组 rectangles ,其中 rectangles[i] = [li, wi] 表示第 i 个矩形的长度为 li 、宽度为 wi 。如果存在 k 同时满足 k <= li 和 k <= wi ,就可以将第 i 个矩形切成边长为 k 的正方形。例如,矩形 [4,6] 可以切成边长最大为 4 的正方形。设 maxLen 为可以从矩形数组 rectangles 切分得到的 最大正方形 的边长。返回可以切出边长为 maxLen 的正方形的矩形 数目 。 + +## 解题思路 + +- 简单题。扫描数组中的每一个矩形,先找到边长较小的那条边,作为正方形的边长。扫描过程中动态更新最大的正方形边长,并累加计数。循环一遍结束,输出最终计数值即可。 + +## 代码 + +```go +package leetcode + +func countGoodRectangles(rectangles [][]int) int { + minLength, count := 0, 0 + for i, _ := range rectangles { + minSide := 0 + if rectangles[i][0] <= rectangles[i][1] { + minSide = rectangles[i][0] + } else { + minSide = rectangles[i][1] + } + if minSide > minLength { + minLength = minSide + count = 1 + } else if minSide == minLength { + count++ + } + } + return count +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md b/website/content/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md new file mode 100644 index 000000000..2534015d5 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md @@ -0,0 +1,62 @@ +# [1732. Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude/) + + +## 题目 + +There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. + +You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i` and `i + 1` for all (`0 <= i < n)`. Return *the **highest altitude** of a point.* + +**Example 1:** + +``` +Input: gain = [-5,1,5,0,-7] +Output: 1 +Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1. +``` + +**Example 2:** + +``` +Input: gain = [-4,-3,-2,-1,4,3,2] +Output: 0 +Explanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0. +``` + +**Constraints:** + +- `n == gain.length` +- `1 <= n <= 100` +- `100 <= gain[i] <= 100` + +## 题目大意 + +有一个自行车手打算进行一场公路骑行,这条路线总共由 n + 1 个不同海拔的点组成。自行车手从海拔为 0 的点 0 开始骑行。给你一个长度为 n 的整数数组 gain ,其中 gain[i] 是点 i 和点 i + 1 的 净海拔高度差(0 <= i < n)。请你返回 最高点的海拔 。 + +## 解题思路 + +- 简单题。循环数组依次从第一个海拔点开始还原每个海拔点,动态记录最大高度。循环结束输出最大高度即可。 + +## 代码 + +```go +package leetcode + +func largestAltitude(gain []int) int { + max, height := 0, 0 + for _, g := range gain { + height += g + if height > max { + max = height + } + } + return max +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1736.Latest-Time-by-Replacing-Hidden-Digits.md b/website/content/ChapterFour/1700~1799/1736.Latest-Time-by-Replacing-Hidden-Digits.md new file mode 100644 index 000000000..060275793 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1736.Latest-Time-by-Replacing-Hidden-Digits.md @@ -0,0 +1,82 @@ +# [1736. Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/) + + +## 题目 + +You are given a string `time` in the form of `hh:mm`, where some of the digits in the string are hidden (represented by `?`). + +The valid times are those inclusively between `00:00` and `23:59`. + +Return *the latest valid time you can get from* `time` *by replacing the hidden* *digits*. + +**Example 1:** + +``` +Input: time = "2?:?0" +Output: "23:50" +Explanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50. +``` + +**Example 2:** + +``` +Input: time = "0?:3?" +Output: "09:39" +``` + +**Example 3:** + +``` +Input: time = "1?:22" +Output: "19:22" +``` + +**Constraints:** + +- `time` is in the format `hh:mm`. +- It is guaranteed that you can produce a valid time from the given string. + +## 题目大意 + +给你一个字符串 time ,格式为 hh:mm(小时:分钟),其中某几位数字被隐藏(用 ? 表示)。有效的时间为 00:00 到 23:59 之间的所有时间,包括 00:00 和 23:59 。替换 time 中隐藏的数字,返回你可以得到的最晚有效时间。 + +## 解题思路 + +- 简单题。根据题意,需要找到最晚的有效时间。枚举时间 4 个位置即可。如果第 3 个位置是 ?,那么它最晚时间是 5;如果第 4 个位置是 ?,那么它最晚时间是 9;如果第 2 个位置是 ?,那么它最晚时间是 9;如果第 1 个位置是 ?,根据第 2 个位置判断,如果第 2 个位置是大于 3 的数,那么第一个位置最晚时间是 1,如果第 2 个位置是小于 3 的数那么第一个位置最晚时间是 2 。按照上述规则即可还原最晚时间。 + +## 代码 + +```go +package leetcode + +func maximumTime(time string) string { + timeb := []byte(time) + if timeb[3] == '?' { + timeb[3] = '5' + } + if timeb[4] == '?' { + timeb[4] = '9' + } + if timeb[0] == '?' { + if int(timeb[1]-'0') > 3 && int(timeb[1]-'0') < 10 { + timeb[0] = '1' + } else { + timeb[0] = '2' + } + } + if timeb[1] == '?' { + timeb[1] = '9' + } + if timeb[0] == '2' && timeb[1] == '9' { + timeb[1] = '3' + } + return string(timeb) +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1742.Maximum-Number-of-Balls-in-a-Box.md b/website/content/ChapterFour/1700~1799/1742.Maximum-Number-of-Balls-in-a-Box.md new file mode 100644 index 000000000..9e06e974e --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1742.Maximum-Number-of-Balls-in-a-Box.md @@ -0,0 +1,88 @@ +# [1742. Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box/) + + +## 题目 + +You are working in a ball factory where you have `n` balls numbered from `lowLimit` up to `highLimit` **inclusive** (i.e., `n == highLimit - lowLimit + 1`), and an infinite number of boxes numbered from `1` to `infinity`. + +Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number `321` will be put in the box number `3 + 2 + 1 = 6` and the ball number `10` will be put in the box number `1 + 0 = 1`. + +Given two integers `lowLimit` and `highLimit`, return *the number of balls in the box with the most balls.* + +**Example 1:** + +``` +Input: lowLimit = 1, highLimit = 10 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 ... +Ball Count: 2 1 1 1 1 1 1 1 1 0 0 ... +Box 1 has the most number of balls with 2 balls. +``` + +**Example 2:** + +``` +Input: lowLimit = 5, highLimit = 15 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 ... +Ball Count: 1 1 1 1 2 2 1 1 1 0 0 ... +Boxes 5 and 6 have the most number of balls with 2 balls in each. + +``` + +**Example 3:** + +``` +Input: lowLimit = 19, highLimit = 28 +Output: 2 +Explanation: +Box Number: 1 2 3 4 5 6 7 8 9 10 11 12 ... +Ball Count: 0 1 1 1 1 1 1 1 1 2 0 0 ... +Box 10 has the most number of balls with 2 balls. + +``` + +**Constraints:** + +- `1 <= lowLimit <= highLimit <= 10^5` + +## 题目大意 + +你在一家生产小球的玩具厂工作,有 n 个小球,编号从 lowLimit 开始,到 highLimit 结束(包括 lowLimit 和 highLimit ,即 n == highLimit - lowLimit + 1)。另有无限数量的盒子,编号从 1 到 infinity 。你的工作是将每个小球放入盒子中,其中盒子的编号应当等于小球编号上每位数字的和。例如,编号 321 的小球应当放入编号 3 + 2 + 1 = 6 的盒子,而编号 10 的小球应当放入编号 1 + 0 = 1 的盒子。 + +给你两个整数 lowLimit 和 highLimit ,返回放有最多小球的盒子中的小球数量。如果有多个盒子都满足放有最多小球,只需返回其中任一盒子的小球数量。 + +## 解题思路 + +- 简单题。循环遍历一遍数组,依次计算出所有小球的编号各位数字累加和,并且动态维护放有小球最多的数目。循环结束,输出最多小球个数即可。 + +## 代码 + +```go +package leetcode + +func countBalls(lowLimit int, highLimit int) int { + buckets, maxBall := [46]int{}, 0 + for i := lowLimit; i <= highLimit; i++ { + t := 0 + for j := i; j > 0; { + t += j % 10 + j = j / 10 + } + buckets[t]++ + if buckets[t] > maxBall { + maxBall = buckets[t] + } + } + return maxBall +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md b/website/content/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md new file mode 100644 index 000000000..3f285687b --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md @@ -0,0 +1,74 @@ +# [1748. Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements/) + + +## 题目 + +You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. + +Return *the **sum** of all the unique elements of* `nums`. + +**Example 1:** + +``` +Input: nums = [1,2,3,2] +Output: 4 +Explanation: The unique elements are [1,3], and the sum is 4. +``` + +**Example 2:** + +``` +Input: nums = [1,1,1,1,1] +Output: 0 +Explanation: There are no unique elements, and the sum is 0. +``` + +**Example 3:** + +``` +Input: nums = [1,2,3,4,5] +Output: 15 +Explanation: The unique elements are [1,2,3,4,5], and the sum is 15. +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `1 <= nums[i] <= 100` + +## 题目大意 + +给你一个整数数组 `nums` 。数组中唯一元素是那些只出现 **恰好一次** 的元素。请你返回 `nums` 中唯一元素的 **和** 。 + +## 解题思路 + +- 简单题。利用 map 统计出每个元素出现的频次。再累加所有频次为 1 的元素,最后输出累加和即可。 + +## 代码 + +```go +package leetcode + +func sumOfUnique(nums []int) int { + freq, res := make(map[int]int), 0 + for _, v := range nums { + if _, ok := freq[v]; !ok { + freq[v] = 0 + } + freq[v]++ + } + for k, v := range freq { + if v == 1 { + res += k + } + } + return res +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1752.Check-if-Array-Is-Sorted-and-Rotated.md b/website/content/ChapterFour/1700~1799/1752.Check-if-Array-Is-Sorted-and-Rotated.md new file mode 100644 index 000000000..b72e4ff6e --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1752.Check-if-Array-Is-Sorted-and-Rotated.md @@ -0,0 +1,93 @@ +# [1752. Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/) + + +## 题目 + +Given an array `nums`, return `true` *if the array was originally sorted in non-decreasing order, then rotated **some** number of positions (including zero)*. Otherwise, return `false`. + +There may be **duplicates** in the original array. + +**Note:** An array `A` rotated by `x` positions results in an array `B` of the same length such that `A[i] == B[(i+x) % A.length]`, where `%` is the modulo operation. + +**Example 1:** + +``` +Input: nums = [3,4,5,1,2] +Output: true +Explanation: [1,2,3,4,5] is the original sorted array. +You can rotate the array by x = 3 positions to begin on the the element of value 3: [3,4,5,1,2]. +``` + +**Example 2:** + +``` +Input: nums = [2,1,3,4] +Output: false +Explanation: There is no sorted array once rotated that can make nums. +``` + +**Example 3:** + +``` +Input: nums = [1,2,3] +Output: true +Explanation: [1,2,3] is the original sorted array. +You can rotate the array by x = 0 positions (i.e. no rotation) to make nums. +``` + +**Example 4:** + +``` +Input: nums = [1,1,1] +Output: true +Explanation: [1,1,1] is the original sorted array. +You can rotate any number of positions to make nums. +``` + +**Example 5:** + +``` +Input: nums = [2,1] +Output: true +Explanation: [1,2] is the original sorted array. +You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1]. +``` + +**Constraints:** + +- `1 <= nums.length <= 100` +- `1 <= nums[i] <= 100` + +## 题目大意 + +给你一个数组 nums 。nums 的源数组中,所有元素与 nums 相同,但按非递减顺序排列。如果 nums 能够由源数组轮转若干位置(包括 0 个位置)得到,则返回 true ;否则,返回 false 。源数组中可能存在 重复项 。 + +## 解题思路 + +- 简单题。从头扫描一遍数组,找出相邻两个元素递减的数对。如果递减的数对只有 1 个,则有可能是轮转得来的,超过 1 个,则返回 false。题干里面还提到可能有多个重复元素,针对这一情况还需要判断一下 `nums[0]` 和 `nums[len(nums)-1]` 。如果是相同元素,`nums[0] < nums[len(nums)-1]`,并且数组中间还存在一对递减的数对,这时候也是 false。判断好上述这 2 种情况,本题得解。 + +## 代码 + +```go +package leetcode + +func check(nums []int) bool { + count := 0 + for i := 0; i < len(nums)-1; i++ { + if nums[i] > nums[i+1] { + count++ + if count > 1 || nums[0] < nums[len(nums)-1] { + return false + } + } + } + return true +} +``` + + +---------------------------------------------- + diff --git a/website/content/ChapterFour/1700~1799/1758.Minimum-Changes-To-Make-Alternating-Binary-String.md b/website/content/ChapterFour/1700~1799/1758.Minimum-Changes-To-Make-Alternating-Binary-String.md new file mode 100644 index 000000000..5675af855 --- /dev/null +++ b/website/content/ChapterFour/1700~1799/1758.Minimum-Changes-To-Make-Alternating-Binary-String.md @@ -0,0 +1,75 @@ +# [1758. Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string/) + + +## 题目 + +You are given a string `s` consisting only of the characters `'0'` and `'1'`. In one operation, you can change any `'0'` to `'1'` or vice versa. + +The string is called alternating if no two adjacent characters are equal. For example, the string `"010"` is alternating, while the string `"0100"` is not. + +Return *the **minimum** number of operations needed to make* `s` *alternating*. + +**Example 1:** + +``` +Input: s = "0100" +Output: 1 +Explanation: If you change the last character to '1', s will be "0101", which is alternating. +``` + +**Example 2:** + +``` +Input: s = "10" +Output: 0 +Explanation: s is already alternating. +``` + +**Example 3:** + +``` +Input: s = "1111" +Output: 2 +Explanation: You need two operations to reach "0101" or "1010". +``` + +**Constraints:** + +- `1 <= s.length <= 104` +- `s[i]` is either `'0'` or `'1'`. + +## 题目大意 + +你将得到一个仅包含字符“ 0”和“ 1”的字符串 `s`。 在一项操作中,你可以将任何 `'0'` 更改为 `'1'`,反之亦然。 如果两个相邻字符都不相等,则该字符串称为交替字符串。 例如,字符串“ 010”是交替的,而字符串“ 0100”则不是。 返回使 `s` 交替所需的最小操作数。 + +## 解题思路 + +- 简单题。利用数组下标奇偶交替性来判断交替字符串。交替字符串有 2 种,一个是 `'01010101……'` 还有一个是 `'1010101010……'`,这两个只需要计算出一个即可,另外一个利用 `len(s) - res` 就是答案。 + +## 代码 + +```go +package leetcode + +func minOperations(s string) int { + res := 0 + for i := 0; i < len(s); i++ { + if int(s[i]-'0') != i%2 { + res++ + } + } + return min(res, len(s)-res) +} + +func min(a, b int) int { + if a > b { + return b + } + return a +} +``` + + +---------------------------------------------- + + diff --git a/website/content/ChapterTwo/Array.md b/website/content/ChapterTwo/Array.md index edaccf0c5..0e87abcc3 100644 --- a/website/content/ChapterTwo/Array.md +++ b/website/content/ChapterTwo/Array.md @@ -11,7 +11,7 @@ weight: 1 |0001|Two Sum|[Go]({{< relref "/ChapterFour/0001~0099/0001.Two-Sum.md" >}})|Easy| O(n)| O(n)||46.4%| |0004|Median of Two Sorted Arrays|[Go]({{< relref "/ChapterFour/0001~0099/0004.Median-of-Two-Sorted-Arrays.md" >}})|Hard||||31.0%| |0011|Container With Most Water|[Go]({{< relref "/ChapterFour/0001~0099/0011.Container-With-Most-Water.md" >}})|Medium| O(n)| O(1)||52.4%| -|0015|3Sum|[Go]({{< relref "/ChapterFour/0001~0099/0015.3Sum.md" >}})|Medium| O(n^2)| O(n)|❤️|27.9%| +|0015|3Sum|[Go]({{< relref "/ChapterFour/0001~0099/0015.3Sum.md" >}})|Medium| O(n^2)| O(n)|❤️|28.0%| |0016|3Sum Closest|[Go]({{< relref "/ChapterFour/0001~0099/0016.3Sum-Closest.md" >}})|Medium| O(n^2)| O(1)|❤️|46.3%| |0018|4Sum|[Go]({{< relref "/ChapterFour/0001~0099/0018.4Sum.md" >}})|Medium| O(n^3)| O(n^2)|❤️|34.8%| |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%| @@ -23,7 +23,7 @@ weight: 1 |0039|Combination Sum|[Go]({{< relref "/ChapterFour/0001~0099/0039.Combination-Sum.md" >}})|Medium| O(n log n)| O(n)||59.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%| +|0042|Trapping Rain Water|[Go]({{< relref "/ChapterFour/0001~0099/0042.Trapping-Rain-Water.md" >}})|Hard| O(n)| O(1)|❤️|51.1%| |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%| @@ -35,7 +35,7 @@ weight: 1 |0063|Unique Paths II|[Go]({{< relref "/ChapterFour/0001~0099/0063.Unique-Paths-II.md" >}})|Medium| O(n^2)| O(n^2)||35.2%| |0064|Minimum Path Sum|[Go]({{< relref "/ChapterFour/0001~0099/0064.Minimum-Path-Sum.md" >}})|Medium| O(n^2)| O(n^2)||56.1%| |0066|Plus One|[Go]({{< relref "/ChapterFour/0001~0099/0066.Plus-One.md" >}})|Easy||||42.3%| -|0074|Search a 2D Matrix|[Go]({{< relref "/ChapterFour/0001~0099/0074.Search-a-2D-Matrix.md" >}})|Medium||||37.6%| +|0074|Search a 2D Matrix|[Go]({{< relref "/ChapterFour/0001~0099/0074.Search-a-2D-Matrix.md" >}})|Medium||||37.7%| |0075|Sort Colors|[Go]({{< relref "/ChapterFour/0001~0099/0075.Sort-Colors.md" >}})|Medium| O(n)| O(1)|❤️|49.3%| |0078|Subsets|[Go]({{< relref "/ChapterFour/0001~0099/0078.Subsets.md" >}})|Medium| O(n^2)| O(n)|❤️|64.9%| |0079|Word Search|[Go]({{< relref "/ChapterFour/0001~0099/0079.Word-Search.md" >}})|Medium| O(n^2)| O(n^2)|❤️|36.7%| @@ -101,7 +101,7 @@ weight: 1 |0891|Sum of Subsequence Widths|[Go]({{< relref "/ChapterFour/0800~0899/0891.Sum-of-Subsequence-Widths.md" >}})|Hard| O(n log n)| O(1)||33.0%| |0896|Monotonic Array|[Go]({{< relref "/ChapterFour/0800~0899/0896.Monotonic-Array.md" >}})|Easy||||58.0%| |0907|Sum of Subarray Minimums|[Go]({{< relref "/ChapterFour/0900~0999/0907.Sum-of-Subarray-Minimums.md" >}})|Medium| O(n)| O(n)|❤️|33.1%| -|0914|X of a Kind in a Deck of Cards|[Go]({{< relref "/ChapterFour/0900~0999/0914.X-of-a-Kind-in-a-Deck-of-Cards.md" >}})|Easy||||34.3%| +|0914|X of a Kind in a Deck of Cards|[Go]({{< relref "/ChapterFour/0900~0999/0914.X-of-a-Kind-in-a-Deck-of-Cards.md" >}})|Easy||||34.2%| |0918|Maximum Sum Circular Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0918.Maximum-Sum-Circular-Subarray.md" >}})|Medium||||34.2%| |0922|Sort Array By Parity II|[Go]({{< relref "/ChapterFour/0900~0999/0922.Sort-Array-By-Parity-II.md" >}})|Easy| O(n)| O(1)||70.5%| |0969|Pancake Sorting|[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})|Medium| O(n)| O(1)|❤️|68.6%| @@ -120,7 +120,7 @@ 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.6%| +|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.7%| |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.6%| |1184|Distance Between Bus Stops|[Go]({{< relref "/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md" >}})|Easy||||54.1%| @@ -151,14 +151,21 @@ weight: 1 |1480|Running Sum of 1d Array|[Go]({{< relref "/ChapterFour/1400~1499/1480.Running-Sum-of-1d-Array.md" >}})|Easy||||89.2%| |1512|Number of Good Pairs|[Go]({{< relref "/ChapterFour/1500~1599/1512.Number-of-Good-Pairs.md" >}})|Easy||||87.7%| |1539|Kth Missing Positive Number|[Go]({{< relref "/ChapterFour/1500~1599/1539.Kth-Missing-Positive-Number.md" >}})|Easy||||55.1%| +|1608|Special Array With X Elements Greater Than or Equal X|[Go]({{< relref "/ChapterFour/1600~1699/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X.md" >}})|Easy||||61.6%| |1619|Mean of Array After Removing Some Elements|[Go]({{< relref "/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements.md" >}})|Easy||||65.2%| |1629|Slowest Key|[Go]({{< relref "/ChapterFour/1600~1699/1629.Slowest-Key.md" >}})|Easy||||59.2%| |1636|Sort Array by Increasing Frequency|[Go]({{< relref "/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency.md" >}})|Easy||||66.8%| |1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.1%| -|1646|Get Maximum in Generated Array|[Go]({{< relref "/ChapterFour/1600~1699/1646.Get-Maximum-in-Generated-Array.md" >}})|Easy||||53.4%| +|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||||63.0%| |1656|Design an Ordered Stream|[Go]({{< relref "/ChapterFour/1600~1699/1656.Design-an-Ordered-Stream.md" >}})|Easy||||82.3%| |1672|Richest Customer Wealth|[Go]({{< relref "/ChapterFour/1600~1699/1672.Richest-Customer-Wealth.md" >}})|Easy||||88.4%| +|1700|Number of Students Unable to Eat Lunch|[Go]({{< relref "/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md" >}})|Easy||||68.9%| +|1732|Find the Highest Altitude|[Go]({{< relref "/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md" >}})|Easy||||81.6%| +|1742|Maximum Number of Balls in a Box|[Go]({{< relref "/ChapterFour/1700~1799/1742.Maximum-Number-of-Balls-in-a-Box.md" >}})|Easy||||74.8%| +|1748|Sum of Unique Elements|[Go]({{< relref "/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md" >}})|Easy||||77.3%| +|1752|Check if Array Is Sorted and Rotated|[Go]({{< relref "/ChapterFour/1700~1799/1752.Check-if-Array-Is-Sorted-and-Rotated.md" >}})|Easy||||68.3%| +|1758|Minimum Changes To Make Alternating Binary String|[Go]({{< relref "/ChapterFour/1700~1799/1758.Minimum-Changes-To-Make-Alternating-Binary-String.md" >}})|Easy||||60.8%| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------| diff --git a/website/content/ChapterTwo/Backtracking.md b/website/content/ChapterTwo/Backtracking.md index b2a54a20c..d2d71d914 100644 --- a/website/content/ChapterTwo/Backtracking.md +++ b/website/content/ChapterTwo/Backtracking.md @@ -115,7 +115,7 @@ func updateMatrix_BFS(matrix [][]int) [][]int { |0079|Word Search|[Go]({{< relref "/ChapterFour/0001~0099/0079.Word-Search.md" >}})|Medium| O(n^2)| O(n^2)|❤️|36.7%| |0089|Gray Code|[Go]({{< relref "/ChapterFour/0001~0099/0089.Gray-Code.md" >}})|Medium| O(n)| O(1)||50.3%| |0090|Subsets II|[Go]({{< relref "/ChapterFour/0001~0099/0090.Subsets-II.md" >}})|Medium| O(n^2)| O(n)|❤️|48.7%| -|0093|Restore IP Addresses|[Go]({{< relref "/ChapterFour/0001~0099/0093.Restore-IP-Addresses.md" >}})|Medium| O(n)| O(n)|❤️|37.4%| +|0093|Restore IP Addresses|[Go]({{< relref "/ChapterFour/0001~0099/0093.Restore-IP-Addresses.md" >}})|Medium| O(n)| O(n)|❤️|37.5%| |0126|Word Ladder II|[Go]({{< relref "/ChapterFour/0100~0199/0126.Word-Ladder-II.md" >}})|Hard| O(n)| O(n^2)|❤️|23.6%| |0131|Palindrome Partitioning|[Go]({{< relref "/ChapterFour/0100~0199/0131.Palindrome-Partitioning.md" >}})|Medium| O(n)| O(n^2)|❤️|51.8%| |0211|Design Add and Search Words Data Structure|[Go]({{< relref "/ChapterFour/0200~0299/0211.Design-Add-and-Search-Words-Data-Structure.md" >}})|Medium| O(n)| O(n)|❤️|40.1%| @@ -130,8 +130,8 @@ func updateMatrix_BFS(matrix [][]int) [][]int { |0980|Unique Paths III|[Go]({{< relref "/ChapterFour/0900~0999/0980.Unique-Paths-III.md" >}})|Hard| O(n log n)| O(n)||77.2%| |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.3%| +|1641|Count Sorted Vowel Strings|[Go]({{< relref "/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings.md" >}})|Medium||||76.8%| +|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.4%| |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.5%| diff --git a/website/content/ChapterTwo/Binary_Search.md b/website/content/ChapterTwo/Binary_Search.md index 75974bd11..0f2a32441 100644 --- a/website/content/ChapterTwo/Binary_Search.md +++ b/website/content/ChapterTwo/Binary_Search.md @@ -138,7 +138,7 @@ func peakIndexInMountainArray(A []int) int { |0035|Search Insert Position|[Go]({{< relref "/ChapterFour/0001~0099/0035.Search-Insert-Position.md" >}})|Easy||||42.8%| |0050|Pow(x, n)|[Go]({{< relref "/ChapterFour/0001~0099/0050.Powx-n.md" >}})|Medium| O(log n)| O(1)||30.9%| |0069|Sqrt(x)|[Go]({{< relref "/ChapterFour/0001~0099/0069.Sqrtx.md" >}})|Easy| O(log n)| O(1)||35.0%| -|0074|Search a 2D Matrix|[Go]({{< relref "/ChapterFour/0001~0099/0074.Search-a-2D-Matrix.md" >}})|Medium||||37.6%| +|0074|Search a 2D Matrix|[Go]({{< relref "/ChapterFour/0001~0099/0074.Search-a-2D-Matrix.md" >}})|Medium||||37.7%| |0081|Search in Rotated Sorted Array II|[Go]({{< relref "/ChapterFour/0001~0099/0081.Search-in-Rotated-Sorted-Array-II.md" >}})|Medium||||33.5%| |0153|Find Minimum in Rotated Sorted Array|[Go]({{< relref "/ChapterFour/0100~0199/0153.Find-Minimum-in-Rotated-Sorted-Array.md" >}})|Medium||||46.1%| |0154|Find Minimum in Rotated Sorted Array II|[Go]({{< relref "/ChapterFour/0100~0199/0154.Find-Minimum-in-Rotated-Sorted-Array-II.md" >}})|Hard||||42.0%| @@ -146,7 +146,7 @@ func peakIndexInMountainArray(A []int) int { |0167|Two Sum II - Input array is sorted|[Go]({{< relref "/ChapterFour/0100~0199/0167.Two-Sum-II---Input-array-is-sorted.md" >}})|Easy| O(n)| O(1)||55.6%| |0174|Dungeon Game|[Go]({{< relref "/ChapterFour/0100~0199/0174.Dungeon-Game.md" >}})|Hard||||33.3%| |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%| +|0222|Count Complete Tree Nodes|[Go]({{< relref "/ChapterFour/0200~0299/0222.Count-Complete-Tree-Nodes.md" >}})|Medium| O(n)| O(1)||49.2%| |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%| @@ -162,7 +162,7 @@ func peakIndexInMountainArray(A []int) int { |0392|Is Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0392.Is-Subsequence.md" >}})|Easy| O(n)| O(1)||49.5%| |0410|Split Array Largest Sum|[Go]({{< relref "/ChapterFour/0400~0499/0410.Split-Array-Largest-Sum.md" >}})|Hard||||46.3%| |0436|Find Right Interval|[Go]({{< relref "/ChapterFour/0400~0499/0436.Find-Right-Interval.md" >}})|Medium||||48.5%| -|0441|Arranging Coins|[Go]({{< relref "/ChapterFour/0400~0499/0441.Arranging-Coins.md" >}})|Easy||||42.3%| +|0441|Arranging Coins|[Go]({{< relref "/ChapterFour/0400~0499/0441.Arranging-Coins.md" >}})|Easy||||42.4%| |0454|4Sum II|[Go]({{< relref "/ChapterFour/0400~0499/0454.4Sum-II.md" >}})|Medium| O(n^2)| O(n) ||54.6%| |0475|Heaters|[Go]({{< relref "/ChapterFour/0400~0499/0475.Heaters.md" >}})|Medium||||33.6%| |0483|Smallest Good Base|[Go]({{< relref "/ChapterFour/0400~0499/0483.Smallest-Good-Base.md" >}})|Hard||||36.2%| @@ -177,23 +177,23 @@ func peakIndexInMountainArray(A []int) int { |0719|Find K-th Smallest Pair Distance|[Go]({{< relref "/ChapterFour/0700~0799/0719.Find-K-th-Smallest-Pair-Distance.md" >}})|Hard||||32.5%| |0744|Find Smallest Letter Greater Than Target|[Go]({{< relref "/ChapterFour/0700~0799/0744.Find-Smallest-Letter-Greater-Than-Target.md" >}})|Easy||||45.6%| |0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard||||54.8%| -|0786|K-th Smallest Prime Fraction|[Go]({{< relref "/ChapterFour/0700~0799/0786.K-th-Smallest-Prime-Fraction.md" >}})|Hard||||42.3%| +|0786|K-th Smallest Prime Fraction|[Go]({{< relref "/ChapterFour/0700~0799/0786.K-th-Smallest-Prime-Fraction.md" >}})|Hard||||42.4%| |0793|Preimage Size of Factorial Zeroes Function|[Go]({{< relref "/ChapterFour/0700~0799/0793.Preimage-Size-of-Factorial-Zeroes-Function.md" >}})|Hard||||40.7%| |0852|Peak Index in a Mountain Array|[Go]({{< relref "/ChapterFour/0800~0899/0852.Peak-Index-in-a-Mountain-Array.md" >}})|Easy||||71.7%| |0862|Shortest Subarray with Sum at Least K|[Go]({{< relref "/ChapterFour/0800~0899/0862.Shortest-Subarray-with-Sum-at-Least-K.md" >}})|Hard||||25.2%| |0875|Koko Eating Bananas|[Go]({{< relref "/ChapterFour/0800~0899/0875.Koko-Eating-Bananas.md" >}})|Medium||||53.5%| -|0878|Nth Magical Number|[Go]({{< relref "/ChapterFour/0800~0899/0878.Nth-Magical-Number.md" >}})|Hard||||28.8%| +|0878|Nth Magical Number|[Go]({{< relref "/ChapterFour/0800~0899/0878.Nth-Magical-Number.md" >}})|Hard||||28.9%| |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.7%| -|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.6%| +|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.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%| +|1283|Find the Smallest Divisor Given a Threshold|[Go]({{< relref "/ChapterFour/1200~1299/1283.Find-the-Smallest-Divisor-Given-a-Threshold.md" >}})|Medium||||49.5%| |1300|Sum of Mutated Array Closest to Target|[Go]({{< relref "/ChapterFour/1300~1399/1300.Sum-of-Mutated-Array-Closest-to-Target.md" >}})|Medium||||43.2%| |1631|Path With Minimum Effort|[Go]({{< relref "/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort.md" >}})|Medium||||50.1%| |1649|Create Sorted Array through Instructions|[Go]({{< relref "/ChapterFour/1600~1699/1649.Create-Sorted-Array-through-Instructions.md" >}})|Hard||||36.3%| diff --git a/website/content/ChapterTwo/Bit_Manipulation.md b/website/content/ChapterTwo/Bit_Manipulation.md index 1d7c4aa95..9a777db84 100644 --- a/website/content/ChapterTwo/Bit_Manipulation.md +++ b/website/content/ChapterTwo/Bit_Manipulation.md @@ -64,7 +64,7 @@ X & ~X = 0 |0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium| O(n)| O(1)||33.5%| |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.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.0%| |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%| @@ -74,11 +74,10 @@ X & ~X = 0 |0784|Letter Case Permutation|[Go]({{< relref "/ChapterFour/0700~0799/0784.Letter-Case-Permutation.md" >}})|Medium| O(n)| O(1)||66.5%| |0898|Bitwise ORs of Subarrays|[Go]({{< relref "/ChapterFour/0800~0899/0898.Bitwise-ORs-of-Subarrays.md" >}})|Medium| O(n)| O(1)||34.1%| |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%| +|1720|Decode XORed Array|[Go]({{< relref "/ChapterFour/1700~1799/1720.Decode-XORed-Array.md" >}})|Easy||||85.7%| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------| - - ----------------------------------------------