mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 08:02:30 +08:00
1. Add solution 1091、1614、1619、1624、1629、1636、1704
2. ctl strings.TrimSpace question.Title
This commit is contained in:
368
README.md
368
README.md
@ -126,15 +126,15 @@
|
||||
| | Easy | Medium | Hard | Total |
|
||||
|:--------:|:--------:|:--------:|:--------:|:--------:|
|
||||
|Optimizing|38|43|15|96|
|
||||
|Accepted|**254**|**328**|**101**|**683**|
|
||||
|Total|462|922|373|1757|
|
||||
|Perfection Rate|85.0%|86.9%|85.1%|85.9%|
|
||||
|Completion Rate|55.0%|35.6%|27.1%|38.9%|
|
||||
|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%|
|
||||
|------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
||||
|
||||
## 二. 目录
|
||||
|
||||
以下已经收录了 587 道题的题解,还有 13 道题在尝试优化到 beats 100%
|
||||
以下已经收录了 594 道题的题解,还有 13 道题在尝试优化到 beats 100%
|
||||
|
||||
| No. | Title | Solution | Acceptance | Difficulty | Frequency |
|
||||
|:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|
|
||||
@ -159,21 +159,21 @@
|
||||
|0019|Remove Nth Node From End of List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0019.Remove-Nth-Node-From-End-of-List)|35.7%|Medium||
|
||||
|0020|Valid Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0020.Valid-Parentheses)|39.8%|Easy||
|
||||
|0021|Merge Two Sorted Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0021.Merge-Two-Sorted-Lists)|55.9%|Easy||
|
||||
|0022|Generate Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0022.Generate-Parentheses)|65.1%|Medium||
|
||||
|0022|Generate Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0022.Generate-Parentheses)|65.2%|Medium||
|
||||
|0023|Merge k Sorted Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0023.Merge-k-Sorted-Lists)|42.6%|Hard||
|
||||
|0024|Swap Nodes in Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0024.Swap-Nodes-in-Pairs)|52.9%|Medium||
|
||||
|0024|Swap Nodes in Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0024.Swap-Nodes-in-Pairs)|53.0%|Medium||
|
||||
|0025|Reverse Nodes in k-Group|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0025.Reverse-Nodes-in-k-Group)|44.7%|Hard||
|
||||
|0026|Remove Duplicates from Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0026.Remove-Duplicates-from-Sorted-Array)|46.5%|Easy||
|
||||
|0027|Remove Element|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0027.Remove-Element)|49.2%|Easy||
|
||||
|0028|Implement strStr()|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0028.Implement-strStr())|35.2%|Easy||
|
||||
|0029|Divide Two Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0029.Divide-Two-Integers)|16.6%|Medium||
|
||||
|0030|Substring with Concatenation of All Words|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0030.Substring-with-Concatenation-of-All-Words)|26.1%|Hard||
|
||||
|0030|Substring with Concatenation of All Words|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0030.Substring-with-Concatenation-of-All-Words)|26.2%|Hard||
|
||||
|0031|Next Permutation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0031.Next-Permutation)|33.8%|Medium||
|
||||
|0032|Longest Valid Parentheses||29.2%|Hard||
|
||||
|0033|Search in Rotated Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0033.Search-in-Rotated-Sorted-Array)|35.8%|Medium||
|
||||
|0034|Find First and Last Position of Element in Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0034.Find-First-and-Last-Position-of-Element-in-Sorted-Array)|37.2%|Medium||
|
||||
|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.4%|Medium||
|
||||
|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||
|
||||
|0039|Combination Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0039.Combination-Sum)|59.1%|Medium||
|
||||
@ -210,7 +210,7 @@
|
||||
|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.2%|Medium||
|
||||
|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||
|
||||
|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||
|
||||
@ -260,7 +260,7 @@
|
||||
|0120|Triangle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0120.Triangle)|45.7%|Medium||
|
||||
|0121|Best Time to Buy and Sell Stock|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0121.Best-Time-to-Buy-and-Sell-Stock)|51.5%|Easy||
|
||||
|0122|Best Time to Buy and Sell Stock II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0122.Best-Time-to-Buy-and-Sell-Stock-II)|58.4%|Easy||
|
||||
|0123|Best Time to Buy and Sell Stock III||39.8%|Hard||
|
||||
|0123|Best Time to Buy and Sell Stock III||39.9%|Hard||
|
||||
|0124|Binary Tree Maximum Path Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0124.Binary-Tree-Maximum-Path-Sum)|35.4%|Hard||
|
||||
|0125|Valid Palindrome|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0125.Valid-Palindrome)|38.1%|Easy||
|
||||
|0126|Word Ladder II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0126.Word-Ladder-II)|23.6%|Hard||
|
||||
@ -271,7 +271,7 @@
|
||||
|0131|Palindrome Partitioning|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0131.Palindrome-Partitioning)|51.8%|Medium||
|
||||
|0132|Palindrome Partitioning II||31.2%|Hard||
|
||||
|0133|Clone Graph||39.0%|Medium||
|
||||
|0134|Gas Station||41.1%|Medium||
|
||||
|0134|Gas Station||41.2%|Medium||
|
||||
|0135|Candy||32.9%|Hard||
|
||||
|0136|Single Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0136.Single-Number)|66.5%|Easy||
|
||||
|0137|Single Number II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0137.Single-Number-II)|53.7%|Medium||
|
||||
@ -308,16 +308,16 @@
|
||||
|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||
|
||||
|0170|Two Sum III - Data structure design||34.8%|Easy||
|
||||
|0171|Excel Sheet Column Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0171.Excel-Sheet-Column-Number)|56.8%|Easy||
|
||||
|0171|Excel Sheet Column Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0171.Excel-Sheet-Column-Number)|56.9%|Easy||
|
||||
|0172|Factorial Trailing Zeroes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0172.Factorial-Trailing-Zeroes)|38.5%|Easy||
|
||||
|0173|Binary Search Tree Iterator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0173.Binary-Search-Tree-Iterator)|60.0%|Medium||
|
||||
|0174|Dungeon Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0174.Dungeon-Game)|33.2%|Hard||
|
||||
|0174|Dungeon Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0174.Dungeon-Game)|33.3%|Hard||
|
||||
|0175|Combine Two Tables||63.9%|Easy||
|
||||
|0176|Second Highest Salary||33.2%|Easy||
|
||||
|0177|Nth Highest Salary||33.2%|Medium||
|
||||
|0178|Rank Scores||49.9%|Medium||
|
||||
|0179|Largest Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0179.Largest-Number)|30.6%|Medium||
|
||||
|0180|Consecutive Numbers||42.0%|Medium||
|
||||
|0180|Consecutive Numbers||42.1%|Medium||
|
||||
|0181|Employees Earning More Than Their Managers||60.1%|Easy||
|
||||
|0182|Duplicate Emails||64.4%|Easy||
|
||||
|0183|Customers Who Never Order||56.6%|Easy||
|
||||
@ -337,7 +337,7 @@
|
||||
|0197|Rising Temperature||39.8%|Easy||
|
||||
|0198|House Robber|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0198.House-Robber)|42.8%|Medium||
|
||||
|0199|Binary Tree Right Side View|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0199.Binary-Tree-Right-Side-View)|56.3%|Medium||
|
||||
|0200|Number of Islands|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0200.Number-of-Islands)|48.9%|Medium||
|
||||
|0200|Number of Islands|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0200.Number-of-Islands)|49.0%|Medium||
|
||||
|0201|Bitwise AND of Numbers Range|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0201.Bitwise-AND-of-Numbers-Range)|39.6%|Medium||
|
||||
|0202|Happy Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0202.Happy-Number)|51.2%|Easy||
|
||||
|0203|Remove Linked List Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0203.Remove-Linked-List-Elements)|39.2%|Easy||
|
||||
@ -362,7 +362,7 @@
|
||||
|0222|Count Complete Tree Nodes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0222.Count-Complete-Tree-Nodes)|49.1%|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.2%|Easy||
|
||||
|0225|Implement Stack using Queues|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0225.Implement-Stack-using-Queues)|47.3%|Easy||
|
||||
|0226|Invert Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0226.Invert-Binary-Tree)|66.9%|Easy||
|
||||
|0227|Basic Calculator II||38.5%|Medium||
|
||||
|0228|Summary Ranges|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0228.Summary-Ranges)|42.3%|Easy||
|
||||
@ -414,7 +414,7 @@
|
||||
|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||
|
||||
|0277|Find the Celebrity||43.3%|Medium||
|
||||
|0277|Find the Celebrity||43.4%|Medium||
|
||||
|0278|First Bad Version||37.4%|Easy||
|
||||
|0279|Perfect Squares||48.8%|Medium||
|
||||
|0280|Wiggle Sort||64.6%|Medium||
|
||||
@ -428,7 +428,7 @@
|
||||
|0288|Unique Word Abbreviation||23.0%|Medium||
|
||||
|0289|Game of Life||58.1%|Medium||
|
||||
|0290|Word Pattern|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0290.Word-Pattern)|38.3%|Easy||
|
||||
|0291|Word Pattern II||44.1%|Medium||
|
||||
|0291|Word Pattern II||44.2%|Medium||
|
||||
|0292|Nim Game||55.0%|Easy||
|
||||
|0293|Flip Game||61.3%|Easy||
|
||||
|0294|Flip Game II||50.6%|Medium||
|
||||
@ -460,7 +460,7 @@
|
||||
|0320|Generalized Abbreviation||53.6%|Medium||
|
||||
|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.6%|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||
|
||||
|0326|Power of Three|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0326.Power-of-Three)|42.1%|Easy||
|
||||
@ -492,14 +492,14 @@
|
||||
|0352|Data Stream as Disjoint Intervals||48.6%|Hard||
|
||||
|0353|Design Snake Game||35.7%|Medium||
|
||||
|0354|Russian Doll Envelopes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0354.Russian-Doll-Envelopes)|36.2%|Hard||
|
||||
|0355|Design Twitter||31.3%|Medium||
|
||||
|0355|Design Twitter||31.4%|Medium||
|
||||
|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||
|
||||
|0360|Sort Transformed Array||49.6%|Medium||
|
||||
|0361|Bomb Enemy||46.6%|Medium||
|
||||
|0362|Design Hit Counter||65.1%|Medium||
|
||||
|0362|Design Hit Counter||65.2%|Medium||
|
||||
|0363|Max Sum of Rectangle No Larger Than K||38.4%|Hard||
|
||||
|0364|Nested List Weight Sum II||63.6%|Medium||
|
||||
|0365|Water and Jug Problem||31.0%|Medium||
|
||||
@ -534,13 +534,13 @@
|
||||
|0394|Decode String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0394.Decode-String)|52.6%|Medium||
|
||||
|0395|Longest Substring with At Least K Repeating Characters||43.5%|Medium||
|
||||
|0396|Rotate Function||36.7%|Medium||
|
||||
|0397|Integer Replacement|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0397.Integer-Replacement)|33.4%|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||
|
||||
|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.3%|Hard||
|
||||
|0403|Frog Jump||41.4%|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||
|
||||
@ -570,7 +570,7 @@
|
||||
|0430|Flatten a Multilevel Doubly Linked List||56.8%|Medium||
|
||||
|0431|Encode N-ary Tree to Binary Tree||74.6%|Hard||
|
||||
|0432|All O`one Data Structure||33.1%|Hard||
|
||||
|0433|Minimum Genetic Mutation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0433.Minimum-Genetic-Mutation)|43.2%|Medium||
|
||||
|0433|Minimum Genetic Mutation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0433.Minimum-Genetic-Mutation)|43.3%|Medium||
|
||||
|0434|Number of Segments in a String||37.8%|Easy||
|
||||
|0435|Non-overlapping Intervals|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0435.Non-overlapping-Intervals)|43.9%|Medium||
|
||||
|0436|Find Right Interval|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0436.Find-Right-Interval)|48.5%|Medium||
|
||||
@ -578,9 +578,9 @@
|
||||
|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.4%|Easy||
|
||||
|0441|Arranging Coins|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0441.Arranging-Coins)|42.3%|Easy||
|
||||
|0442|Find All Duplicates in an Array||68.9%|Medium||
|
||||
|0443|String Compression||43.4%|Medium||
|
||||
|0443|String Compression||43.5%|Medium||
|
||||
|0444|Sequence Reconstruction||23.5%|Medium||
|
||||
|0445|Add Two Numbers II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0445.Add-Two-Numbers-II)|56.2%|Medium||
|
||||
|0446|Arithmetic Slices II - Subsequence||33.4%|Hard||
|
||||
@ -629,7 +629,7 @@
|
||||
|0489|Robot Room Cleaner||72.4%|Hard||
|
||||
|0490|The Maze||52.7%|Medium||
|
||||
|0491|Increasing Subsequences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0491.Increasing-Subsequences)|47.5%|Medium||
|
||||
|0492|Construct the Rectangle||50.4%|Easy||
|
||||
|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||
|
||||
|0495|Teemo Attacking||56.1%|Medium||
|
||||
@ -671,7 +671,7 @@
|
||||
|0531|Lonely Pixel I||59.5%|Medium||
|
||||
|0532|K-diff Pairs in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0532.K-diff-Pairs-in-an-Array)|35.1%|Medium||
|
||||
|0533|Lonely Pixel II||48.1%|Medium||
|
||||
|0534|Game Play Analysis III||79.1%|Medium||
|
||||
|0534|Game Play Analysis III||79.2%|Medium||
|
||||
|0535|Encode and Decode TinyURL||80.9%|Medium||
|
||||
|0536|Construct Binary Tree from String||50.6%|Medium||
|
||||
|0537|Complex Number Multiplication|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0537.Complex-Number-Multiplication)|68.3%|Medium||
|
||||
@ -687,7 +687,7 @@
|
||||
|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.7%|Medium||
|
||||
|0550|Game Play Analysis IV||45.6%|Medium||
|
||||
|0551|Student Attendance Record I||46.0%|Easy||
|
||||
|0552|Student Attendance Record II||37.3%|Hard||
|
||||
|0553|Optimal Division||57.4%|Medium||
|
||||
@ -710,11 +710,11 @@
|
||||
|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.4%|Medium||
|
||||
|0574|Winning Candidate||51.7%|Medium||
|
||||
|0575|Distribute Candies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0575.Distribute-Candies)|62.0%|Easy||
|
||||
|0573|Squirrel Simulation||54.3%|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.2%|Easy||
|
||||
|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||
|
||||
@ -749,7 +749,7 @@
|
||||
|0609|Find Duplicate File in System||61.0%|Medium||
|
||||
|0610|Triangle Judgement||68.3%|Easy||
|
||||
|0611|Valid Triangle Number||49.2%|Medium||
|
||||
|0612|Shortest Distance in a Plane||61.1%|Medium||
|
||||
|0612|Shortest Distance in a Plane||61.2%|Medium||
|
||||
|0613|Shortest Distance in a Line||79.5%|Easy||
|
||||
|0614|Second Degree Follower||32.4%|Medium||
|
||||
|0615|Average Salary: Departments VS Company||52.1%|Hard||
|
||||
@ -810,7 +810,7 @@
|
||||
|0670|Maximum Swap||45.1%|Medium||
|
||||
|0671|Second Minimum Node In a Binary Tree||42.8%|Easy||
|
||||
|0672|Bulb Switcher II||51.1%|Medium||
|
||||
|0673|Number of Longest Increasing Subsequence||38.4%|Medium||
|
||||
|0673|Number of Longest Increasing Subsequence||38.5%|Medium||
|
||||
|0674|Longest Continuous Increasing Subsequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0674.Longest-Continuous-Increasing-Subsequence)|46.1%|Easy||
|
||||
|0675|Cut Off Trees for Golf Event||35.3%|Hard||
|
||||
|0676|Implement Magic Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0676.Implement-Magic-Dictionary)|55.2%|Medium||
|
||||
@ -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.2%|Medium||
|
||||
|0735|Asteroid Collision|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0735.Asteroid-Collision)|43.3%|Medium||
|
||||
|0736|Parse Lisp Expression||49.8%|Hard||
|
||||
|0737|Sentence Similarity II||46.5%|Medium||
|
||||
|0738|Monotone Increasing Digits||45.6%|Medium||
|
||||
@ -902,11 +902,11 @@
|
||||
|0762|Prime Number of Set Bits in Binary Representation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0762.Prime-Number-of-Set-Bits-in-Binary-Representation)|64.3%|Easy||
|
||||
|0763|Partition Labels|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0763.Partition-Labels)|78.0%|Medium||
|
||||
|0764|Largest Plus Sign||46.5%|Medium||
|
||||
|0765|Couples Holding Hands|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0765.Couples-Holding-Hands)|55.4%|Hard||
|
||||
|0765|Couples Holding Hands|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0765.Couples-Holding-Hands)|55.5%|Hard||
|
||||
|0766|Toeplitz Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0766.Toeplitz-Matrix)|65.8%|Easy||
|
||||
|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.6%|Medium||
|
||||
|0769|Max Chunks To Make Sorted||55.5%|Medium||
|
||||
|0770|Basic Calculator IV||54.1%|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||
|
||||
@ -936,7 +936,7 @@
|
||||
|0796|Rotate String||49.3%|Easy||
|
||||
|0797|All Paths From Source to Target||78.5%|Medium||
|
||||
|0798|Smallest Rotation with Highest Score||44.9%|Hard||
|
||||
|0799|Champagne Tower||44.0%|Medium||
|
||||
|0799|Champagne Tower||44.1%|Medium||
|
||||
|0800|Similar RGB Color||62.2%|Easy||
|
||||
|0801|Minimum Swaps To Make Sequences Increasing||39.0%|Medium||
|
||||
|0802|Find Eventual Safe States|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0802.Find-Eventual-Safe-States)|49.8%|Medium||
|
||||
@ -958,12 +958,12 @@
|
||||
|0818|Race Car||39.8%|Hard||
|
||||
|0819|Most Common Word|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0819.Most-Common-Word)|45.5%|Easy||
|
||||
|0820|Short Encoding of Words||51.5%|Medium||
|
||||
|0821|Shortest Distance to a Character|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0821.Shortest-Distance-to-a-Character)|70.1%|Easy||
|
||||
|0821|Shortest Distance to a Character|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0821.Shortest-Distance-to-a-Character)|70.0%|Easy||
|
||||
|0822|Card Flipping Game||43.6%|Medium||
|
||||
|0823|Binary Trees With Factors||36.5%|Medium||
|
||||
|0824|Goat Latin||66.4%|Easy||
|
||||
|0825|Friends Of Appropriate Ages||44.0%|Medium||
|
||||
|0826|Most Profit Assigning Work|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0826.Most-Profit-Assigning-Work)|39.0%|Medium||
|
||||
|0826|Most Profit Assigning Work|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0826.Most-Profit-Assigning-Work)|39.1%|Medium||
|
||||
|0827|Making A Large Island||47.3%|Hard||
|
||||
|0828|Count Unique Characters of All Substrings of a Given String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0828.Count-Unique-Characters-of-All-Substrings-of-a-Given-String)|46.8%|Hard||
|
||||
|0829|Consecutive Numbers Sum||39.3%|Hard||
|
||||
@ -994,7 +994,7 @@
|
||||
|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||
|
||||
|0857|Minimum Cost to Hire K Workers||50.4%|Hard||
|
||||
|0857|Minimum Cost to Hire K Workers||50.3%|Hard||
|
||||
|0858|Mirror Reflection||59.6%|Medium||
|
||||
|0859|Buddy Strings||29.5%|Easy||
|
||||
|0860|Lemonade Change||51.8%|Easy||
|
||||
@ -1012,7 +1012,7 @@
|
||||
|0872|Leaf-Similar Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0872.Leaf-Similar-Trees)|64.6%|Easy||
|
||||
|0873|Length of Longest Fibonacci Subsequence||48.1%|Medium||
|
||||
|0874|Walking Robot Simulation||36.8%|Easy||
|
||||
|0875|Koko Eating Bananas|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0875.Koko-Eating-Bananas)|53.4%|Medium||
|
||||
|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||
|
||||
@ -1037,7 +1037,7 @@
|
||||
|0897|Increasing Order Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0897.Increasing-Order-Search-Tree)|74.5%|Easy||
|
||||
|0898|Bitwise ORs of Subarrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0898.Bitwise-ORs-of-Subarrays)|34.1%|Medium||
|
||||
|0899|Orderly Queue||53.0%|Hard||
|
||||
|0900|RLE Iterator||55.2%|Medium||
|
||||
|0900|RLE Iterator||55.3%|Medium||
|
||||
|0901|Online Stock Span|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0901.Online-Stock-Span)|61.3%|Medium||
|
||||
|0902|Numbers At Most N Given Digit Set||36.1%|Hard||
|
||||
|0903|Valid Permutations for DI Sequence||54.2%|Hard||
|
||||
@ -1048,7 +1048,7 @@
|
||||
|0908|Smallest Range I||66.4%|Easy||
|
||||
|0909|Snakes and Ladders||39.2%|Medium||
|
||||
|0910|Smallest Range II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0910.Smallest-Range-II)|31.3%|Medium||
|
||||
|0911|Online Election|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0911.Online-Election)|51.3%|Medium||
|
||||
|0911|Online Election|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0911.Online-Election)|51.2%|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||
|
||||
@ -1061,7 +1061,7 @@
|
||||
|0921|Minimum Add to Make Parentheses Valid|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0921.Minimum-Add-to-Make-Parentheses-Valid)|74.7%|Medium||
|
||||
|0922|Sort Array By Parity II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0922.Sort-Array-By-Parity-II)|70.5%|Easy||
|
||||
|0923|3Sum With Multiplicity|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0923.3Sum-With-Multiplicity)|36.2%|Medium||
|
||||
|0924|Minimize Malware Spread|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0924.Minimize-Malware-Spread)|41.8%|Hard||
|
||||
|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||
|
||||
|0927|Three Equal Parts|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0927.Three-Equal-Parts)|34.6%|Hard||
|
||||
@ -1113,9 +1113,9 @@
|
||||
|0973|K Closest Points to Origin|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0973.K-Closest-Points-to-Origin)|64.6%|Medium||
|
||||
|0974|Subarray Sums Divisible by K||50.8%|Medium||
|
||||
|0975|Odd Even Jump||41.5%|Hard||
|
||||
|0976|Largest Perimeter Triangle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0976.Largest-Perimeter-Triangle)|58.6%|Easy||
|
||||
|0976|Largest Perimeter Triangle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0976.Largest-Perimeter-Triangle)|58.5%|Easy||
|
||||
|0977|Squares of a Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0977.Squares-of-a-Sorted-Array)|72.1%|Easy||
|
||||
|0978|Longest Turbulent Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0978.Longest-Turbulent-Subarray)|46.6%|Medium||
|
||||
|0978|Longest Turbulent Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0978.Longest-Turbulent-Subarray)|46.7%|Medium||
|
||||
|0979|Distribute Coins in Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0979.Distribute-Coins-in-Binary-Tree)|69.7%|Medium||
|
||||
|0980|Unique Paths III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0980.Unique-Paths-III)|77.2%|Hard||
|
||||
|0981|Time Based Key-Value Store|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0981.Time-Based-Key-Value-Store)|54.1%|Medium||
|
||||
@ -1138,7 +1138,7 @@
|
||||
|0998|Maximum Binary Tree II||63.9%|Medium||
|
||||
|0999|Available Captures for Rook|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0999.Available-Captures-for-Rook)|67.7%|Easy||
|
||||
|1000|Minimum Cost to Merge Stones||40.4%|Hard||
|
||||
|1001|Grid Illumination||36.8%|Hard||
|
||||
|1001|Grid Illumination||36.7%|Hard||
|
||||
|1002|Find Common Characters|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1002.Find-Common-Characters)|68.6%|Easy||
|
||||
|1003|Check If Word Is Valid After Substitutions|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1003.Check-If-Word-Is-Valid-After-Substitutions)|56.3%|Medium||
|
||||
|1004|Max Consecutive Ones III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1004.Max-Consecutive-Ones-III)|60.7%|Medium||
|
||||
@ -1187,7 +1187,7 @@
|
||||
|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||
|
||||
|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.2%|Easy||
|
||||
|1050|Actors and Directors Who Cooperated At Least Three Times||72.3%|Easy||
|
||||
|1051|Height Checker|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1051.Height-Checker)|72.2%|Easy||
|
||||
|1052|Grumpy Bookstore Owner|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1052.Grumpy-Bookstore-Owner)|55.8%|Medium||
|
||||
|1053|Previous Permutation With One Swap||51.0%|Medium||
|
||||
@ -1198,7 +1198,7 @@
|
||||
|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.7%|Medium||
|
||||
|1061|Lexicographically Smallest Equivalent String||66.6%|Medium||
|
||||
|1062|Longest Repeating Substring||58.3%|Medium||
|
||||
|1063|Number of Valid Subarrays||72.1%|Hard||
|
||||
|1064|Fixed Point||65.2%|Easy||
|
||||
@ -1207,12 +1207,12 @@
|
||||
|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.9%|Medium||
|
||||
|1070|Product Sales Analysis III||49.8%|Medium||
|
||||
|1071|Greatest Common Divisor of Strings||51.2%|Easy||
|
||||
|1072|Flip Columns For Maximum Number of Equal Rows||61.3%|Medium||
|
||||
|1073|Adding Two Negabinary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1073.Adding-Two-Negabinary-Numbers)|34.8%|Medium||
|
||||
|1074|Number of Submatrices That Sum to Target|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1074.Number-of-Submatrices-That-Sum-to-Target)|61.7%|Hard||
|
||||
|1075|Project Employees I||66.2%|Easy||
|
||||
|1075|Project Employees I||66.1%|Easy||
|
||||
|1076|Project Employees II||53.0%|Easy||
|
||||
|1077|Project Employees III||77.4%|Medium||
|
||||
|1078|Occurrences After Bigram|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1078.Occurrences-After-Bigram)|64.9%|Easy||
|
||||
@ -1228,8 +1228,8 @@
|
||||
|1088|Confusing Number II||45.4%|Hard||
|
||||
|1089|Duplicate Zeros|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1089.Duplicate-Zeros)|51.9%|Easy||
|
||||
|1090|Largest Values From Labels||60.0%|Medium||
|
||||
|1091|Shortest Path in Binary Matrix||39.5%|Medium||
|
||||
|1092|Shortest Common Supersequence ||53.0%|Hard||
|
||||
|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||
|
||||
|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||
|
||||
|1095|Find in Mountain Array||36.1%|Hard||
|
||||
@ -1243,7 +1243,7 @@
|
||||
|1103|Distribute Candies to People||63.5%|Easy||
|
||||
|1104|Path In Zigzag Labelled Binary Tree||73.1%|Medium||
|
||||
|1105|Filling Bookcase Shelves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1105.Filling-Bookcase-Shelves)|57.5%|Medium||
|
||||
|1106|Parsing A Boolean Expression||59.2%|Hard||
|
||||
|1106|Parsing A Boolean Expression||59.3%|Hard||
|
||||
|1107|New Users Daily Count||45.8%|Medium||
|
||||
|1108|Defanging an IP Address|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1108.Defanging-an-IP-Address)|88.4%|Easy||
|
||||
|1109|Corporate Flight Bookings||54.3%|Medium||
|
||||
@ -1263,7 +1263,7 @@
|
||||
|1123|Lowest Common Ancestor of Deepest Leaves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1123.Lowest-Common-Ancestor-of-Deepest-Leaves)|68.0%|Medium||
|
||||
|1124|Longest Well-Performing Interval||33.3%|Medium||
|
||||
|1125|Smallest Sufficient Team||47.1%|Hard||
|
||||
|1126|Active Businesses||68.7%|Medium||
|
||||
|1126|Active Businesses||68.6%|Medium||
|
||||
|1127|User Purchase Platform||50.2%|Hard||
|
||||
|1128|Number of Equivalent Domino Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1128.Number-of-Equivalent-Domino-Pairs)|46.6%|Easy||
|
||||
|1129|Shortest Path with Alternating Colors||40.2%|Medium||
|
||||
@ -1275,23 +1275,23 @@
|
||||
|1135|Connecting Cities With Minimum Cost||59.3%|Medium||
|
||||
|1136|Parallel Courses||61.3%|Hard||
|
||||
|1137|N-th Tribonacci Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1137.N-th-Tribonacci-Number)|56.0%|Easy||
|
||||
|1138|Alphabet Board Path||50.9%|Medium||
|
||||
|1138|Alphabet Board Path||51.0%|Medium||
|
||||
|1139|Largest 1-Bordered Square||48.6%|Medium||
|
||||
|1140|Stone Game II||64.7%|Medium||
|
||||
|1141|User Activity for the Past 30 Days I||54.3%|Easy||
|
||||
|1142|User Activity for the Past 30 Days II||35.4%|Easy||
|
||||
|1142|User Activity for the Past 30 Days II||35.3%|Easy||
|
||||
|1143|Longest Common Subsequence||58.7%|Medium||
|
||||
|1144|Decrease Elements To Make Array Zigzag||46.1%|Medium||
|
||||
|1145|Binary Tree Coloring Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1145.Binary-Tree-Coloring-Game)|51.4%|Medium||
|
||||
|1146|Snapshot Array||36.9%|Medium||
|
||||
|1147|Longest Chunked Palindrome Decomposition||59.5%|Hard||
|
||||
|1148|Article Views I||77.1%|Easy||
|
||||
|1149|Article Views II||48.3%|Medium||
|
||||
|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||
|
||||
|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.3%|Easy||
|
||||
|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||
|
||||
@ -1311,12 +1311,12 @@
|
||||
|1171|Remove Zero Sum Consecutive Nodes from Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1171.Remove-Zero-Sum-Consecutive-Nodes-from-Linked-List)|41.4%|Medium||
|
||||
|1172|Dinner Plate Stacks||37.9%|Hard||
|
||||
|1173|Immediate Food Delivery I||82.3%|Easy||
|
||||
|1174|Immediate Food Delivery II||61.7%|Medium||
|
||||
|1174|Immediate Food Delivery II||61.8%|Medium||
|
||||
|1175|Prime Arrangements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1175.Prime-Arrangements)|52.0%|Easy||
|
||||
|1176|Diet Plan Performance||54.0%|Easy||
|
||||
|1177|Can Make Palindrome from Substring||36.1%|Medium||
|
||||
|1178|Number of Valid Words for Each Puzzle||38.8%|Hard||
|
||||
|1179|Reformat Department Table||81.9%|Easy||
|
||||
|1178|Number of Valid Words for Each Puzzle||38.9%|Hard||
|
||||
|1179|Reformat Department Table||82.0%|Easy||
|
||||
|1180|Count Substrings with Only One Distinct Letter||77.6%|Easy||
|
||||
|1181|Before and After Puzzle||44.5%|Medium||
|
||||
|1182|Shortest Distance to Target Color||53.4%|Medium||
|
||||
@ -1331,13 +1331,13 @@
|
||||
|1191|K-Concatenation Maximum Sum||25.3%|Medium||
|
||||
|1192|Critical Connections in a Network||50.0%|Hard||
|
||||
|1193|Monthly Transactions I||69.3%|Medium||
|
||||
|1194|Tournament Winners||51.9%|Hard||
|
||||
|1195|Fizz Buzz Multithreaded||70.5%|Medium||
|
||||
|1196|How Many Apples Can You Put into the Basket||68.0%|Easy||
|
||||
|1194|Tournament Winners||52.0%|Hard||
|
||||
|1195|Fizz Buzz Multithreaded||70.4%|Medium||
|
||||
|1196|How Many Apples Can You Put into the Basket||68.1%|Easy||
|
||||
|1197|Minimum Knight Moves||37.2%|Medium||
|
||||
|1198|Find Smallest Common Element in All Rows||75.2%|Medium||
|
||||
|1199|Minimum Time to Build Blocks||38.5%|Hard||
|
||||
|1200|Minimum Absolute Difference|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1200.Minimum-Absolute-Difference)|66.9%|Easy||
|
||||
|1200|Minimum Absolute Difference|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1200.Minimum-Absolute-Difference)|67.0%|Easy||
|
||||
|1201|Ugly Number III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1201.Ugly-Number-III)|26.4%|Medium||
|
||||
|1202|Smallest String With Swaps|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1202.Smallest-String-With-Swaps)|48.7%|Medium||
|
||||
|1203|Sort Items by Groups Respecting Dependencies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1203.Sort-Items-by-Groups-Respecting-Dependencies)|48.9%|Hard||
|
||||
@ -1346,9 +1346,9 @@
|
||||
|1206|Design Skiplist||59.1%|Hard||
|
||||
|1207|Unique Number of Occurrences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1207.Unique-Number-of-Occurrences)|71.7%|Easy||
|
||||
|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.5%|Medium||
|
||||
|1209|Remove All Adjacent Duplicates in String II||57.6%|Medium||
|
||||
|1210|Minimum Moves to Reach Target with Rotations||46.4%|Hard||
|
||||
|1211|Queries Quality and Percentage||69.8%|Easy||
|
||||
|1211|Queries Quality and Percentage||69.9%|Easy||
|
||||
|1212|Team Scores in Football Tournament||56.8%|Medium||
|
||||
|1213|Intersection of Three Sorted Arrays||79.3%|Easy||
|
||||
|1214|Two Sum BSTs||67.7%|Medium||
|
||||
@ -1356,7 +1356,7 @@
|
||||
|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.7%|Medium||
|
||||
|1219|Path with Maximum Gold||65.6%|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||
|
||||
@ -1372,7 +1372,7 @@
|
||||
|1232|Check If It Is a Straight Line|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1232.Check-If-It-Is-a-Straight-Line)|43.7%|Easy||
|
||||
|1233|Remove Sub-Folders from the Filesystem||62.0%|Medium||
|
||||
|1234|Replace the Substring for Balanced String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1234.Replace-the-Substring-for-Balanced-String)|34.3%|Medium||
|
||||
|1235|Maximum Profit in Job Scheduling|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1235.Maximum-Profit-in-Job-Scheduling)|47.3%|Hard||
|
||||
|1235|Maximum Profit in Job Scheduling|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1235.Maximum-Profit-in-Job-Scheduling)|47.4%|Hard||
|
||||
|1236|Web Crawler||64.7%|Medium||
|
||||
|1237|Find Positive Integer Solution for a Given Equation||69.6%|Medium||
|
||||
|1238|Circular Permutation in Binary Representation||66.1%|Medium||
|
||||
@ -1382,10 +1382,10 @@
|
||||
|1242|Web Crawler Multithreaded||47.7%|Medium||
|
||||
|1243|Array Transformation||50.2%|Easy||
|
||||
|1244|Design A Leaderboard||65.7%|Medium||
|
||||
|1245|Tree Diameter||61.2%|Medium||
|
||||
|1245|Tree Diameter||61.3%|Medium||
|
||||
|1246|Palindrome Removal||45.9%|Hard||
|
||||
|1247|Minimum Swaps to Make Strings Equal||62.9%|Medium||
|
||||
|1248|Count Number of Nice Subarrays||56.2%|Medium||
|
||||
|1248|Count Number of Nice Subarrays||56.1%|Medium||
|
||||
|1249|Minimum Remove to Make Valid Parentheses||63.7%|Medium||
|
||||
|1250|Check If It Is a Good Array||56.2%|Hard||
|
||||
|1251|Average Selling Price||82.5%|Easy||
|
||||
@ -1393,7 +1393,7 @@
|
||||
|1253|Reconstruct a 2-Row Binary Matrix||41.5%|Medium||
|
||||
|1254|Number of Closed Islands|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1254.Number-of-Closed-Islands)|61.6%|Medium||
|
||||
|1255|Maximum Score Words Formed by Letters||69.9%|Hard||
|
||||
|1256|Encode Number||67.6%|Medium||
|
||||
|1256|Encode Number||67.7%|Medium||
|
||||
|1257|Smallest Common Region||60.8%|Medium||
|
||||
|1258|Synonymous Sentences||63.7%|Medium||
|
||||
|1259|Handshakes That Don't Cross||54.2%|Hard||
|
||||
@ -1406,23 +1406,23 @@
|
||||
|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.2%|Hard||
|
||||
|1270|All People Report to the Given Manager||88.2%|Medium||
|
||||
|1271|Hexspeak||55.3%|Easy||
|
||||
|1269|Number of Ways to Stay in the Same Place After Some Steps||43.3%|Hard||
|
||||
|1270|All People Report to the Given Manager||88.3%|Medium||
|
||||
|1271|Hexspeak||55.4%|Easy||
|
||||
|1272|Remove Interval||57.9%|Medium||
|
||||
|1273|Delete Tree Nodes||62.3%|Medium||
|
||||
|1274|Number of Ships in a Rectangle||66.3%|Hard||
|
||||
|1274|Number of Ships in a Rectangle||66.2%|Hard||
|
||||
|1275|Find Winner on a Tic Tac Toe Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1275.Find-Winner-on-a-Tic-Tac-Toe-Game)|52.9%|Easy||
|
||||
|1276|Number of Burgers with No Waste of Ingredients||50.0%|Medium||
|
||||
|1277|Count Square Submatrices with All Ones||72.9%|Medium||
|
||||
|1278|Palindrome Partitioning III||60.9%|Hard||
|
||||
|1279|Traffic Light Controlled Intersection||75.7%|Easy||
|
||||
|1280|Students and Examinations||74.7%|Easy||
|
||||
|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||
|
||||
|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||86.9%|Medium||
|
||||
|1285|Find the Start and End Number of Continuous Ranges||87.0%|Medium||
|
||||
|1286|Iterator for Combination||70.9%|Medium||
|
||||
|1287|Element Appearing More Than 25% In Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1287.Element-Appearing-More-Than-25%-In-Sorted-Array)|60.2%|Easy||
|
||||
|1288|Remove Covered Intervals||57.2%|Medium||
|
||||
@ -1431,10 +1431,10 @@
|
||||
|1291|Sequential Digits||57.4%|Medium||
|
||||
|1292|Maximum Side Length of a Square with Sum Less than or Equal to Threshold||50.5%|Medium||
|
||||
|1293|Shortest Path in a Grid with Obstacles Elimination||43.0%|Hard||
|
||||
|1294|Weather Type in Each Country||66.7%|Easy||
|
||||
|1294|Weather Type in Each Country||66.6%|Easy||
|
||||
|1295|Find Numbers with Even Number of Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1295.Find-Numbers-with-Even-Number-of-Digits)|79.2%|Easy||
|
||||
|1296|Divide Array in Sets of K Consecutive Numbers||55.4%|Medium||
|
||||
|1297|Maximum Number of Occurrences of a Substring||49.8%|Medium||
|
||||
|1297|Maximum Number of Occurrences of a Substring||49.9%|Medium||
|
||||
|1298|Maximum Candies You Can Get from Boxes||59.7%|Hard||
|
||||
|1299|Replace Elements with Greatest Element on Right Side|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1299.Replace-Elements-with-Greatest-Element-on-Right-Side)|74.5%|Easy||
|
||||
|1300|Sum of Mutated Array Closest to Target|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1300.Sum-of-Mutated-Array-Closest-to-Target)|43.2%|Medium||
|
||||
@ -1445,11 +1445,11 @@
|
||||
|1305|All Elements in Two Binary Search Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1305.All-Elements-in-Two-Binary-Search-Trees)|77.8%|Medium||
|
||||
|1306|Jump Game III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1306.Jump-Game-III)|62.6%|Medium||
|
||||
|1307|Verbal Arithmetic Puzzle||36.9%|Hard||
|
||||
|1308|Running Total for Different Genders||87.3%|Medium||
|
||||
|1308|Running Total for Different Genders||87.4%|Medium||
|
||||
|1309|Decrypt String from Alphabet to Integer Mapping||77.4%|Easy||
|
||||
|1310|XOR Queries of a Subarray||69.2%|Medium||
|
||||
|1311|Get Watched Videos by Your Friends||44.1%|Medium||
|
||||
|1312|Minimum Insertion Steps to Make a String Palindrome||59.5%|Hard||
|
||||
|1312|Minimum Insertion Steps to Make a String Palindrome||59.6%|Hard||
|
||||
|1313|Decompress Run-Length Encoded List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1313.Decompress-Run-Length-Encoded-List)|85.4%|Easy||
|
||||
|1314|Matrix Block Sum||73.7%|Medium||
|
||||
|1315|Sum of Nodes with Even-Valued Grandparent||84.2%|Medium||
|
||||
@ -1458,9 +1458,9 @@
|
||||
|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||70.9%|Medium||
|
||||
|1322|Ads Performance||58.0%|Easy||
|
||||
|1323|Maximum 69 Number||78.0%|Easy||
|
||||
|1321|Restaurant Growth||71.0%|Medium||
|
||||
|1322|Ads Performance||57.9%|Easy||
|
||||
|1323|Maximum 69 Number||77.9%|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||
|
||||
@ -1475,7 +1475,7 @@
|
||||
|1335|Minimum Difficulty of a Job Schedule||56.9%|Hard||
|
||||
|1336|Number of Transactions per Visit||48.0%|Hard||
|
||||
|1337|The K Weakest Rows in a Matrix||70.5%|Easy||
|
||||
|1338|Reduce Array Size to The Half||67.6%|Medium||
|
||||
|1338|Reduce Array Size to The Half||67.7%|Medium||
|
||||
|1339|Maximum Product of Splitted Binary Tree||38.3%|Medium||
|
||||
|1340|Jump Game V||59.2%|Hard||
|
||||
|1341|Movie Rating||58.6%|Medium||
|
||||
@ -1489,21 +1489,21 @@
|
||||
|1349|Maximum Students Taking Exam||44.2%|Hard||
|
||||
|1350|Students With Invalid Departments||90.4%|Easy||
|
||||
|1351|Count Negative Numbers in a Sorted Matrix||75.9%|Easy||
|
||||
|1352|Product of the Last K Numbers||44.2%|Medium||
|
||||
|1352|Product of the Last K Numbers||44.3%|Medium||
|
||||
|1353|Maximum Number of Events That Can Be Attended||30.5%|Medium||
|
||||
|1354|Construct Target Array With Multiple Sums||31.3%|Hard||
|
||||
|1355|Activity Participants||74.3%|Medium||
|
||||
|1356|Sort Integers by The Number of 1 Bits||69.7%|Easy||
|
||||
|1357|Apply Discount Every n Orders||66.7%|Medium||
|
||||
|1358|Number of Substrings Containing All Three Characters||60.6%|Medium||
|
||||
|1358|Number of Substrings Containing All Three Characters||60.5%|Medium||
|
||||
|1359|Count All Valid Pickup and Delivery Options||56.5%|Hard||
|
||||
|1360|Number of Days Between Two Dates||46.8%|Easy||
|
||||
|1361|Validate Binary Tree Nodes||43.9%|Medium||
|
||||
|1362|Closest Divisors||57.6%|Medium||
|
||||
|1363|Largest Multiple of Three||34.0%|Hard||
|
||||
|1363|Largest Multiple of Three||34.1%|Hard||
|
||||
|1364|Number of Trusted Contacts of a Customer||78.5%|Medium||
|
||||
|1365|How Many Numbers Are Smaller Than the Current Number||86.0%|Easy||
|
||||
|1366|Rank Teams by Votes||55.0%|Medium||
|
||||
|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||
|
||||
@ -1512,11 +1512,11 @@
|
||||
|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||
|
||||
|1375|Bulb Switcher III||64.1%|Medium||
|
||||
|1375|Bulb Switcher III||64.2%|Medium||
|
||||
|1376|Time Needed to Inform All Employees||56.4%|Medium||
|
||||
|1377|Frog Position After T Seconds||35.2%|Hard||
|
||||
|1378|Replace Employee ID With The Unique Identifier||89.9%|Easy||
|
||||
|1379|Find a Corresponding Node of a Binary Tree in a Clone of That Tree||84.8%|Medium||
|
||||
|1378|Replace Employee ID With The Unique Identifier||90.0%|Easy||
|
||||
|1379|Find a Corresponding Node of a Binary Tree in a Clone of That Tree||84.7%|Medium||
|
||||
|1380|Lucky Numbers in a Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1380.Lucky-Numbers-in-a-Matrix)|70.8%|Easy||
|
||||
|1381|Design a Stack With Increment Operation||76.1%|Medium||
|
||||
|1382|Balance a Binary Search Tree||76.2%|Medium||
|
||||
@ -1532,10 +1532,10 @@
|
||||
|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.7%|Medium||
|
||||
|1395|Count Number of Teams||78.6%|Medium||
|
||||
|1396|Design Underground System||69.5%|Medium||
|
||||
|1397|Find All Good Strings||38.3%|Hard||
|
||||
|1398|Customers Who Bought Products A and B but Not C||82.0%|Medium||
|
||||
|1397|Find All Good Strings||38.4%|Hard||
|
||||
|1398|Customers Who Bought Products A and B but Not C||81.9%|Medium||
|
||||
|1399|Count Largest Group||65.3%|Easy||
|
||||
|1400|Construct K Palindrome Strings||62.8%|Medium||
|
||||
|1401|Circle and Rectangle Overlapping||42.4%|Medium||
|
||||
@ -1572,20 +1572,20 @@
|
||||
|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.8%|Easy||
|
||||
|1435|Create a Session Bar Chart||77.7%|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.7%|Easy||
|
||||
|1441|Build an Array With Stack Operations||69.8%|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||
|
||||
|1445|Apples & Oranges||90.6%|Medium||
|
||||
|1446|Consecutive Characters||60.9%|Easy||
|
||||
|1447|Simplified Fractions||62.3%|Medium||
|
||||
|1448|Count Good Nodes in Binary Tree||70.5%|Medium||
|
||||
|1448|Count Good Nodes in Binary Tree||70.6%|Medium||
|
||||
|1449|Form Largest Integer With Digits That Add up to Target||43.9%|Hard||
|
||||
|1450|Number of Students Doing Homework at a Given Time||77.3%|Easy||
|
||||
|1451|Rearrange Words in a Sentence||59.4%|Medium||
|
||||
@ -1602,7 +1602,7 @@
|
||||
|1462|Course Schedule IV||44.5%|Medium||
|
||||
|1463|Cherry Pickup II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1463.Cherry-Pickup-II)|69.3%|Hard||
|
||||
|1464|Maximum Product of Two Elements in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1464.Maximum-Product-of-Two-Elements-in-an-Array)|77.2%|Easy||
|
||||
|1465|Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts||32.5%|Medium||
|
||||
|1465|Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts||32.6%|Medium||
|
||||
|1466|Reorder Routes to Make All Paths Lead to the City Zero||61.6%|Medium||
|
||||
|1467|Probability of a Two Boxes Having The Same Number of Distinct Balls||61.0%|Hard||
|
||||
|1468|Calculate Salaries||81.7%|Medium||
|
||||
@ -1654,30 +1654,30 @@
|
||||
|1514|Path with Maximum Probability||40.0%|Medium||
|
||||
|1515|Best Position for a Service Centre||37.0%|Hard||
|
||||
|1516|Move Sub-Tree of N-Ary Tree||63.2%|Hard||
|
||||
|1517|Find Users With Valid E-Mails||71.8%|Easy||
|
||||
|1517|Find Users With Valid E-Mails||71.9%|Easy||
|
||||
|1518|Water Bottles||60.6%|Easy||
|
||||
|1519|Number of Nodes in the Sub-Tree With the Same Label||37.0%|Medium||
|
||||
|1520|Maximum Number of Non-Overlapping Substrings||36.2%|Hard||
|
||||
|1521|Find a Value of a Mysterious Function Closest to Target||44.3%|Hard||
|
||||
|1522|Diameter of N-Ary Tree||69.3%|Medium||
|
||||
|1523|Count Odd Numbers in an Interval Range||54.7%|Easy||
|
||||
|1523|Count Odd Numbers in an Interval Range||54.6%|Easy||
|
||||
|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.2%|Easy||
|
||||
|1527|Patients With a Condition||69.1%|Easy||
|
||||
|1528|Shuffle String||85.8%|Easy||
|
||||
|1529|Bulb Switcher IV||70.9%|Medium||
|
||||
|1530|Number of Good Leaf Nodes Pairs||56.1%|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||
|
||||
|1533|Find the Index of the Large Integer||54.7%|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||
|
||||
|1536|Minimum Swaps to Arrange a Binary Grid||43.4%|Medium||
|
||||
|1537|Get the Maximum Score||36.4%|Hard||
|
||||
|1538|Guess the Majority in a Hidden Array||61.3%|Medium||
|
||||
|1538|Guess the Majority in a Hidden Array||61.2%|Medium||
|
||||
|1539|Kth Missing Positive Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1539.Kth-Missing-Positive-Number)|55.1%|Easy||
|
||||
|1540|Can Convert String in K Moves||30.7%|Medium||
|
||||
|1540|Can Convert String in K Moves||30.8%|Medium||
|
||||
|1541|Minimum Insertions to Balance a Parentheses String||42.7%|Medium||
|
||||
|1542|Find Longest Awesome Substring||36.6%|Hard||
|
||||
|1543|Fix Product Name Format||67.7%|Easy||
|
||||
@ -1696,11 +1696,11 @@
|
||||
|1556|Thousand Separator||57.8%|Easy||
|
||||
|1557|Minimum Number of Vertices to Reach All Nodes||75.5%|Medium||
|
||||
|1558|Minimum Numbers of Function Calls to Make Target Array||63.5%|Medium||
|
||||
|1559|Detect Cycles in 2D Grid||44.3%|Hard||
|
||||
|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||
|
||||
|1562|Find Latest Group of Size M||39.5%|Medium||
|
||||
|1563|Stone Game V||40.0%|Hard||
|
||||
|1563|Stone Game V||40.1%|Hard||
|
||||
|1564|Put Boxes Into the Warehouse I||65.8%|Medium||
|
||||
|1565|Unique Orders and Customers Per Month||82.9%|Easy||
|
||||
|1566|Detect Pattern of Length M Repeated K or More Times||42.4%|Easy||
|
||||
@ -1708,8 +1708,8 @@
|
||||
|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||
|
||||
|1570|Dot Product of Two Sparse Vectors||91.2%|Medium||
|
||||
|1571|Warehouse Manager||89.9%|Easy||
|
||||
|1572|Matrix Diagonal Sum||78.3%|Easy||
|
||||
|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||
|
||||
|1575|Count All Possible Routes||57.3%|Hard||
|
||||
@ -1718,15 +1718,15 @@
|
||||
|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||
|
||||
|1581|Customer Who Visited but Did Not Make Any Transactions||89.6%|Easy||
|
||||
|1582|Special Positions in a Binary Matrix||64.3%|Easy||
|
||||
|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||
|
||||
|1585|Check If String Is Transformable With Substring Sort Operations||48.2%|Hard||
|
||||
|1586|Binary Search Tree Iterator II||66.5%|Medium||
|
||||
|1587|Bank Account Summary II||90.0%|Easy||
|
||||
|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.8%|Medium||
|
||||
|1589|Maximum Sum Obtained of Any Permutation||34.7%|Medium||
|
||||
|1590|Make Sum Divisible by P||27.0%|Medium||
|
||||
|1591|Strange Printer II||55.1%|Hard||
|
||||
|1592|Rearrange Spaces Between Words||43.8%|Easy||
|
||||
@ -1734,14 +1734,14 @@
|
||||
|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||62.9%|Hard||
|
||||
|1597|Build Binary Expression Tree From Infix Expression||63.0%|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.7%|Hard||
|
||||
|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||
|
||||
|1604|Alert Using Same Key-Card Three or More Times in a One Hour Period||42.2%|Medium||
|
||||
|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||
|
||||
@ -1750,76 +1750,76 @@
|
||||
|1610|Maximum Number of Visible Points||29.2%|Hard||
|
||||
|1611|Minimum One Bit Operations to Make Integers Zero||57.5%|Hard||
|
||||
|1612|Check If Two Expression Trees are Equivalent||69.8%|Medium||
|
||||
|1613|Find the Missing IDs||73.5%|Medium||
|
||||
|1614|Maximum Nesting Depth of the Parentheses||83.1%|Easy||
|
||||
|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||
|
||||
|1615|Maximal Network Rank||51.9%|Medium||
|
||||
|1616|Split Two Strings to Make Palindrome||36.2%|Medium||
|
||||
|1617|Count Subtrees With Max Distance Between Cities||63.8%|Hard||
|
||||
|1618|Maximum Font to Fit a Sentence in a Screen||57.5%|Medium||
|
||||
|1619|Mean of Array After Removing Some Elements||65.2%|Easy||
|
||||
|1619|Mean of Array After Removing Some Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1619.Mean-of-Array-After-Removing-Some-Elements)|65.2%|Easy||
|
||||
|1620|Coordinate With Maximum Network Quality||37.1%|Medium||
|
||||
|1621|Number of Sets of K Non-Overlapping Line Segments||41.0%|Medium||
|
||||
|1622|Fancy Sequence||15.3%|Hard||
|
||||
|1623|All Valid Triplets That Can Represent a Country||88.9%|Easy||
|
||||
|1624|Largest Substring Between Two Equal Characters||58.9%|Easy||
|
||||
|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||
|
||||
|1627|Graph Connectivity With Threshold||38.6%|Hard||
|
||||
|1628|Design an Expression Tree With Evaluate Function||80.4%|Medium||
|
||||
|1629|Slowest Key||59.2%|Easy||
|
||||
|1628|Design an Expression Tree With Evaluate Function||80.5%|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||
|
||||
|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||
|
||||
|1633|Percentage of Users Attended a Contest||72.0%|Easy||
|
||||
|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.3%|Hard||
|
||||
|1636|Sort Array by Increasing Frequency||66.8%|Easy||
|
||||
|1635|Hopper Company Queries I||56.4%|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||
|
||||
|1640|Check Array Formation Through Concatenation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1640.Check-Array-Formation-Through-Concatenation)|60.2%|Easy||
|
||||
|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||
|
||||
|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.5%|Easy||
|
||||
|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||
|
||||
|1647|Minimum Deletions to Make Character Frequencies Unique|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique)|54.5%|Medium||
|
||||
|1648|Sell Diminishing-Valued Colored Balls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1648.Sell-Diminishing-Valued-Colored-Balls)|30.8%|Medium||
|
||||
|1649|Create Sorted Array through Instructions|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1649.Create-Sorted-Array-through-Instructions)|36.3%|Hard||
|
||||
|1650|Lowest Common Ancestor of a Binary Tree III||77.0%|Medium||
|
||||
|1651|Hopper Company Queries III||67.5%|Hard||
|
||||
|1652|Defuse the Bomb|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1652.Defuse-the-Bomb)|63.0%|Easy||
|
||||
|1653|Minimum Deletions to Make String Balanced|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1653.Minimum-Deletions-to-Make-String-Balanced)|50.6%|Medium||
|
||||
|1654|Minimum Jumps to Reach Home|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1654.Minimum-Jumps-to-Reach-Home)|26.1%|Medium||
|
||||
|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||
|
||||
|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.7%|Medium||
|
||||
|1660|Correct a Binary Tree||77.5%|Medium||
|
||||
|1661|Average Time of Process per Machine||79.3%|Easy||
|
||||
|1662|Check If Two String Arrays are Equivalent|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1662.Check-If-Two-String-Arrays-are-Equivalent)|83.3%|Easy||
|
||||
|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)|60.6%|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.4%|Medium||
|
||||
|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||
|
||||
|1669|Merge In Between Linked Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1669.Merge-In-Between-Linked-Lists)|77.0%|Medium||
|
||||
|1670|Design Front Middle Back Queue|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1670.Design-Front-Middle-Back-Queue)|54.5%|Medium||
|
||||
|1671|Minimum Number of Removals to Make Mountain Array||45.5%|Hard||
|
||||
|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.7%|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||
|
||||
|1675|Minimize Deviation in Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1675.Minimize-Deviation-in-Array)|48.5%|Hard||
|
||||
|1676|Lowest Common Ancestor of a Binary Tree IV||78.5%|Medium||
|
||||
|1677|Product's Worth Over Invoices||73.8%|Easy||
|
||||
|1676|Lowest Common Ancestor of a Binary Tree IV||78.6%|Medium||
|
||||
|1677|Product's Worth Over Invoices||73.9%|Easy||
|
||||
|1678|Goal Parser Interpretation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1678.Goal-Parser-Interpretation)|85.7%|Easy||
|
||||
|1679|Max Number of K-Sum Pairs|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1679.Max-Number-of-K-Sum-Pairs)|54.2%|Medium||
|
||||
|1680|Concatenation of Consecutive Binary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1680.Concatenation-of-Consecutive-Binary-Numbers)|52.4%|Medium||
|
||||
|1681|Minimum Incompatibility|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1681.Minimum-Incompatibility)|35.4%|Hard||
|
||||
|1682|Longest Palindromic Subsequence II||50.5%|Medium||
|
||||
|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||
|
||||
@ -1828,73 +1828,77 @@
|
||||
|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.1%|Hard||
|
||||
|1693|Daily Leads and Partners||90.9%|Easy||
|
||||
|1694|Reformat Phone Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1694.Reformat-Phone-Number)|66.3%|Easy||
|
||||
|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||
|
||||
|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||
|
||||
|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.9%|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.5%|Medium||
|
||||
|1698|Number of Distinct Substrings in a String||57.0%|Medium||
|
||||
|1699|Number of Calls Between Two Persons||86.6%|Medium||
|
||||
|1700|Number of Students Unable to Eat Lunch||69.0%|Easy||
|
||||
|1700|Number of Students Unable to Eat Lunch||68.9%|Easy||
|
||||
|1701|Average Waiting Time||61.5%|Medium||
|
||||
|1702|Maximum Binary String After Change||60.4%|Medium||
|
||||
|1703|Minimum Adjacent Swaps for K Consecutive Ones||40.2%|Hard||
|
||||
|1704|Determine if String Halves Are Alike||77.6%|Easy||
|
||||
|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||
|
||||
|1706|Where Will the Ball Fall||59.2%|Medium||
|
||||
|1707|Maximum XOR With an Element From Array||47.2%|Hard||
|
||||
|1708|Largest Subarray Length K||63.9%|Easy||
|
||||
|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||
|
||||
|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||
|
||||
|1715|Count Apples and Oranges||79.3%|Medium||
|
||||
|1716|Calculate Money in Leetcode Bank||67.3%|Easy||
|
||||
|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.2%|Hard||
|
||||
|1720|Decode XORed Array||85.8%|Easy||
|
||||
|1719|Number Of Ways To Reconstruct A Tree||39.1%|Hard||
|
||||
|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||
|
||||
|1723|Find Minimum Time to Finish All Jobs||44.3%|Hard||
|
||||
|1724|Checking Existence of Edge Length Limited Paths II||58.8%|Hard||
|
||||
|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||
|
||||
|1726|Tuple with Same Product||55.4%|Medium||
|
||||
|1727|Largest Submatrix With Rearrangements||58.4%|Medium||
|
||||
|1728|Cat and Mouse II||40.9%|Hard||
|
||||
|1729|Find Followers Count||72.3%|Easy||
|
||||
|1730|Shortest Path to Get Food||58.6%|Medium||
|
||||
|1727|Largest Submatrix With Rearrangements||58.3%|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||
|
||||
|1733|Minimum Number of People to Teach||36.7%|Medium||
|
||||
|1734|Decode XORed Permutation||51.0%|Medium||
|
||||
|1735|Count Ways to Make Array With Product||49.0%|Hard||
|
||||
|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||
|
||||
|1738|Find Kth Largest XOR Coordinate Value||62.4%|Medium||
|
||||
|1739|Building Boxes||49.5%|Hard||
|
||||
|1740|Find Distance in a Binary Tree||70.8%|Medium||
|
||||
|1741|Find Total Time Spent by Each Employee||91.0%|Easy||
|
||||
|1742|Maximum Number of Balls in a Box||74.9%|Easy||
|
||||
|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||
|
||||
|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.9%|Hard||
|
||||
|1746|Maximum Subarray Sum After One Operation||62.8%|Medium||
|
||||
|1747|Leetflex Banned Accounts||70.0%|Medium||
|
||||
|1748|Sum of Unique Elements||77.4%|Easy||
|
||||
|1749|Maximum Absolute Sum of Any Subarray||49.7%|Medium||
|
||||
|1750|Minimum Length of String After Deleting Similar Ends||41.5%|Medium||
|
||||
|1751|Maximum Number of Events That Can Be Attended II||47.2%|Hard||
|
||||
|1752|Check if Array Is Sorted and Rotated||69.3%|Easy||
|
||||
|1753|Maximum Score From Removing Stones||60.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||
|
||||
|1751|Maximum Number of Events That Can Be Attended II||47.4%|Hard||
|
||||
|1752|Check if Array Is Sorted and Rotated||68.8%|Easy||
|
||||
|1753|Maximum Score From Removing Stones||60.5%|Medium||
|
||||
|1754|Largest Merge Of Two Strings||38.7%|Medium||
|
||||
|1755|Closest Subsequence Sum||35.4%|Hard||
|
||||
|1756|Design Most Recently Used Queue||79.7%|Medium||
|
||||
|1757|Recyclable and Low Fat Products||100.0%|Easy||
|
||||
|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||
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// LeetCodeProblemAll define
|
||||
@ -53,8 +54,8 @@ func ConvertMdModelFromSsp(problems []StatStatusPairs) []Mdrow {
|
||||
for _, problem := range problems {
|
||||
res := Mdrow{}
|
||||
res.FrontendQuestionID = problem.Stat.FrontendQuestionID
|
||||
res.QuestionTitle = problem.Stat.QuestionTitle
|
||||
res.QuestionTitleSlug = problem.Stat.QuestionTitleSlug
|
||||
res.QuestionTitle = strings.TrimSpace(problem.Stat.QuestionTitle)
|
||||
res.QuestionTitleSlug = strings.TrimSpace(problem.Stat.QuestionTitleSlug)
|
||||
res.Acceptance = fmt.Sprintf("%.1f%%", (problem.Stat.TotalAcs/problem.Stat.TotalSubmitted)*100)
|
||||
res.Difficulty = DifficultyMap[problem.Difficulty.Level]
|
||||
res.Frequency = fmt.Sprintf("%f", problem.Frequency)
|
||||
@ -69,8 +70,8 @@ func ConvertMdModelFromIds(problemsMap map[int]StatStatusPairs, ids []int) []Mdr
|
||||
for _, v := range ids {
|
||||
res, problem := Mdrow{}, problemsMap[v]
|
||||
res.FrontendQuestionID = problem.Stat.FrontendQuestionID
|
||||
res.QuestionTitle = problem.Stat.QuestionTitle
|
||||
res.QuestionTitleSlug = problem.Stat.QuestionTitleSlug
|
||||
res.QuestionTitle = strings.TrimSpace(problem.Stat.QuestionTitle)
|
||||
res.QuestionTitleSlug = strings.TrimSpace(problem.Stat.QuestionTitleSlug)
|
||||
res.Acceptance = fmt.Sprintf("%.1f%%", (problem.Stat.TotalAcs/problem.Stat.TotalSubmitted)*100)
|
||||
res.Difficulty = DifficultyMap[problem.Difficulty.Level]
|
||||
res.Frequency = fmt.Sprintf("%f", problem.Frequency)
|
||||
|
@ -22,7 +22,7 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
|
||||
id := mdrows[solutionIds[i]-1].FrontendQuestionID
|
||||
if solutionIds[i] == int(id) {
|
||||
//fmt.Printf("id = %v i = %v solutionIds = %v\n", id, i, solutionIds[i])
|
||||
mdrows[id-1].SolutionPath = fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", id, strings.Replace(mdrows[id-1].QuestionTitle, " ", "-", -1)))
|
||||
mdrows[id-1].SolutionPath = fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", id, strings.Replace(strings.TrimSpace(mdrows[id-1].QuestionTitle), " ", "-", -1)))
|
||||
} else {
|
||||
fmt.Printf("序号出错了 solutionIds = %v id = %v\n", solutionIds[i], id)
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/halfrost/LeetCode-Go/ctl/util"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/halfrost/LeetCode-Go/ctl/util"
|
||||
)
|
||||
|
||||
// Graphql define
|
||||
@ -84,8 +85,8 @@ func ConvertMdModelFromQuestions(questions []Question) []Mdrow {
|
||||
res := Mdrow{}
|
||||
v, _ := strconv.Atoi(question.QuestionFrontendID)
|
||||
res.FrontendQuestionID = int32(v)
|
||||
res.QuestionTitle = question.Title
|
||||
res.QuestionTitleSlug = question.TitleSlug
|
||||
res.QuestionTitle = strings.TrimSpace(question.Title)
|
||||
res.QuestionTitleSlug = strings.TrimSpace(question.TitleSlug)
|
||||
q, err := question.generateTagStatus()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
@ -121,8 +122,8 @@ func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdro
|
||||
if util.BinarySearch(solutionIds, int(row.FrontendQuestionID)) != -1 {
|
||||
tmp := TagList{}
|
||||
tmp.FrontendQuestionID = row.FrontendQuestionID
|
||||
tmp.QuestionTitle = row.QuestionTitle
|
||||
s1 := strings.Replace(row.QuestionTitle, " ", "-", -1)
|
||||
tmp.QuestionTitle = strings.TrimSpace(row.QuestionTitle)
|
||||
s1 := strings.Replace(tmp.QuestionTitle, " ", "-", -1)
|
||||
s2 := strings.Replace(s1, "'", "", -1)
|
||||
s3 := strings.Replace(s2, "%", "", -1)
|
||||
s4 := strings.Replace(s3, "(", "", -1)
|
||||
|
@ -0,0 +1,54 @@
|
||||
package leetcode
|
||||
|
||||
var dir = [][]int{
|
||||
{-1, -1},
|
||||
{-1, 0},
|
||||
{-1, 1},
|
||||
{0, 1},
|
||||
{0, -1},
|
||||
{1, -1},
|
||||
{1, 0},
|
||||
{1, 1},
|
||||
}
|
||||
|
||||
func shortestPathBinaryMatrix(grid [][]int) int {
|
||||
visited := make([][]bool, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
visited = append(visited, make([]bool, len(grid[0])))
|
||||
}
|
||||
dis := make([][]int, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
dis = append(dis, make([]int, len(grid[0])))
|
||||
}
|
||||
if grid[0][0] == 1 {
|
||||
return -1
|
||||
}
|
||||
if len(grid) == 1 && len(grid[0]) == 1 {
|
||||
return 1
|
||||
}
|
||||
|
||||
queue := []int{0}
|
||||
visited[0][0], dis[0][0] = true, 1
|
||||
for len(queue) > 0 {
|
||||
cur := queue[0]
|
||||
queue = queue[1:]
|
||||
curx, cury := cur/len(grid[0]), cur%len(grid[0])
|
||||
for d := 0; d < 8; d++ {
|
||||
nextx := curx + dir[d][0]
|
||||
nexty := cury + dir[d][1]
|
||||
if isInBoard(grid, nextx, nexty) && !visited[nextx][nexty] && grid[nextx][nexty] == 0 {
|
||||
queue = append(queue, nextx*len(grid[0])+nexty)
|
||||
visited[nextx][nexty] = true
|
||||
dis[nextx][nexty] = dis[curx][cury] + 1
|
||||
if nextx == len(grid)-1 && nexty == len(grid[0])-1 {
|
||||
return dis[nextx][nexty]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func isInBoard(board [][]int, x, y int) bool {
|
||||
return x >= 0 && x < len(board) && y >= 0 && y < len(board[0])
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1091 struct {
|
||||
para1091
|
||||
ans1091
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1091 struct {
|
||||
grid [][]int
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1091 struct {
|
||||
one int
|
||||
}
|
||||
|
||||
func Test_Problem1091(t *testing.T) {
|
||||
|
||||
qs := []question1091{
|
||||
|
||||
{
|
||||
para1091{[][]int{{0, 1}, {1, 0}}},
|
||||
ans1091{2},
|
||||
},
|
||||
|
||||
{
|
||||
para1091{[][]int{{0, 0, 0}, {1, 1, 0}, {1, 1, 0}}},
|
||||
ans1091{4},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1091------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1091, q.para1091
|
||||
fmt.Printf("【input】:%v 【output】:%v\n", p, shortestPathBinaryMatrix(p.grid))
|
||||
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
114
leetcode/1091.Shortest-Path-in-Binary-Matrix/README.md
Normal file
114
leetcode/1091.Shortest-Path-in-Binary-Matrix/README.md
Normal file
@ -0,0 +1,114 @@
|
||||
# [1091. Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
In an N by N square grid, each cell is either empty (0) or blocked (1).
|
||||
|
||||
A *clear path from top-left to bottom-right* has length `k` if and only if it is composed of cells `C_1, C_2, ..., C_k` such that:
|
||||
|
||||
- Adjacent cells `C_i` and `C_{i+1}` are connected 8-directionally (ie., they are different and share an edge or corner)
|
||||
- `C_1` is at location `(0, 0)` (ie. has value `grid[0][0]`)
|
||||
- `C_k` is at location `(N-1, N-1)` (ie. has value `grid[N-1][N-1]`)
|
||||
- If `C_i` is located at `(r, c)`, then `grid[r][c]` is empty (ie. `grid[r][c] == 0`).
|
||||
|
||||
Return the length of the shortest such clear path from top-left to bottom-right. If such a path does not exist, return -1.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: [[0,1],[1,0]]
|
||||
Output: 2
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: [[0,0,0],[1,1,0],[1,1,0]]
|
||||
Output: 4
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Note:**
|
||||
|
||||
1. `1 <= grid.length == grid[0].length <= 100`
|
||||
2. `grid[r][c]` is `0` or `1`
|
||||
|
||||
## 题目大意
|
||||
|
||||
在一个 N × N 的方形网格中,每个单元格有两种状态:空(0)或者阻塞(1)。一条从左上角到右下角、长度为 k 的畅通路径,由满足下述条件的单元格 C_1, C_2, ..., C_k 组成:
|
||||
|
||||
- 相邻单元格 C_i 和 C_{i+1} 在八个方向之一上连通(此时,C_i 和 C_{i+1} 不同且共享边或角)
|
||||
- C_1 位于 (0, 0)(即,值为 grid[0][0])
|
||||
- C_k 位于 (N-1, N-1)(即,值为 grid[N-1][N-1])
|
||||
- 如果 C_i 位于 (r, c),则 grid[r][c] 为空(即,grid[r][c] == 0)
|
||||
|
||||
返回这条从左上角到右下角的最短畅通路径的长度。如果不存在这样的路径,返回 -1 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 这一题是简单的找最短路径。利用 BFS 从左上角逐步扩展到右下角,便可以很容易求解。注意每轮扩展需要考虑 8 个方向。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
var dir = [][]int{
|
||||
{-1, -1},
|
||||
{-1, 0},
|
||||
{-1, 1},
|
||||
{0, 1},
|
||||
{0, -1},
|
||||
{1, -1},
|
||||
{1, 0},
|
||||
{1, 1},
|
||||
}
|
||||
|
||||
func shortestPathBinaryMatrix(grid [][]int) int {
|
||||
visited := make([][]bool, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
visited = append(visited, make([]bool, len(grid[0])))
|
||||
}
|
||||
dis := make([][]int, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
dis = append(dis, make([]int, len(grid[0])))
|
||||
}
|
||||
if grid[0][0] == 1 {
|
||||
return -1
|
||||
}
|
||||
if len(grid) == 1 && len(grid[0]) == 1 {
|
||||
return 1
|
||||
}
|
||||
|
||||
queue := []int{0}
|
||||
visited[0][0], dis[0][0] = true, 1
|
||||
for len(queue) > 0 {
|
||||
cur := queue[0]
|
||||
queue = queue[1:]
|
||||
curx, cury := cur/len(grid[0]), cur%len(grid[0])
|
||||
for d := 0; d < 8; d++ {
|
||||
nextx := curx + dir[d][0]
|
||||
nexty := cury + dir[d][1]
|
||||
if isInBoard(grid, nextx, nexty) && !visited[nextx][nexty] && grid[nextx][nexty] == 0 {
|
||||
queue = append(queue, nextx*len(grid[0])+nexty)
|
||||
visited[nextx][nexty] = true
|
||||
dis[nextx][nexty] = dis[curx][cury] + 1
|
||||
if nextx == len(grid)-1 && nexty == len(grid[0])-1 {
|
||||
return dis[nextx][nexty]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func isInBoard(board [][]int, x, y int) bool {
|
||||
return x >= 0 && x < len(board) && y >= 0 && y < len(board[0])
|
||||
}
|
||||
```
|
@ -0,0 +1,21 @@
|
||||
package leetcode
|
||||
|
||||
func maxDepth(s string) int {
|
||||
res, cur := 0, 0
|
||||
for _, c := range s {
|
||||
if c == '(' {
|
||||
cur++
|
||||
res = max(res, cur)
|
||||
} else if c == ')' {
|
||||
cur--
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1614 struct {
|
||||
para1614
|
||||
ans1614
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1614 struct {
|
||||
p string
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1614 struct {
|
||||
one int
|
||||
}
|
||||
|
||||
func Test_Problem1614(t *testing.T) {
|
||||
|
||||
qs := []question1614{
|
||||
|
||||
{
|
||||
para1614{"(1+(2*3)+((8)/4))+1"},
|
||||
ans1614{3},
|
||||
},
|
||||
|
||||
{
|
||||
para1614{"(1)+((2))+(((3)))"},
|
||||
ans1614{3},
|
||||
},
|
||||
|
||||
{
|
||||
para1614{"1+(2*3)/(2-1)"},
|
||||
ans1614{1},
|
||||
},
|
||||
|
||||
{
|
||||
para1614{"1"},
|
||||
ans1614{0},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1614------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1614, q.para1614
|
||||
fmt.Printf("【input】:%v 【output】:%v \n", p, maxDepth(p.p))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
102
leetcode/1614.Maximum-Nesting-Depth-of-the-Parentheses/README.md
Normal file
102
leetcode/1614.Maximum-Nesting-Depth-of-the-Parentheses/README.md
Normal file
@ -0,0 +1,102 @@
|
||||
# [1614. Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/)
|
||||
|
||||
## 题目
|
||||
|
||||
A string is a **valid parentheses string** (denoted **VPS**) if it meets one of the following:
|
||||
|
||||
- It is an empty string `""`, or a single character not equal to `"("` or `")"`,
|
||||
- It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are **VPS**'s, or
|
||||
- It can be written as `(A)`, where `A` is a **VPS**.
|
||||
|
||||
We can similarly define the **nesting depth** `depth(S)` of any VPS `S` as follows:
|
||||
|
||||
- `depth("") = 0`
|
||||
- `depth(C) = 0`, where `C` is a string with a single character not equal to `"("` or `")"`.
|
||||
- `depth(A + B) = max(depth(A), depth(B))`, where `A` and `B` are **VPS**'s.
|
||||
- `depth("(" + A + ")") = 1 + depth(A)`, where `A` is a **VPS**.
|
||||
|
||||
For example, `""`, `"()()"`, and `"()(()())"` are **VPS**'s (with nesting depths 0, 1, and 2), and `")("` and `"(()"` are not **VPS**'s.
|
||||
|
||||
Given a **VPS** represented as string `s`, return *the **nesting depth** of* `s`.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "(1+(2*3)+((8)/4))+1"
|
||||
Output: 3
|
||||
Explanation: Digit 8 is inside of 3 nested parentheses in the string.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "(1)+((2))+(((3)))"
|
||||
Output: 3
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "1+(2*3)/(2-1)"
|
||||
Output: 1
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "1"
|
||||
Output: 0
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= s.length <= 100`
|
||||
- `s` consists of digits `0-9` and characters `'+'`, `'-'`, `'*'`, `'/'`, `'('`, and `')'`.
|
||||
- It is guaranteed that parentheses expression `s` is a **VPS**.
|
||||
|
||||
## 题目大意
|
||||
|
||||
如果字符串满足以下条件之一,则可以称之为 有效括号字符串(valid parentheses string,可以简写为 VPS):
|
||||
|
||||
- 字符串是一个空字符串 "",或者是一个不为 "(" 或 ")" 的单字符。
|
||||
- 字符串可以写为 AB(A 与 B 字符串连接),其中 A 和 B 都是 有效括号字符串 。
|
||||
- 字符串可以写为 (A),其中 A 是一个 有效括号字符串 。
|
||||
|
||||
类似地,可以定义任何有效括号字符串 S 的 嵌套深度 depth(S):
|
||||
|
||||
- depth("") = 0
|
||||
- depth(C) = 0,其中 C 是单个字符的字符串,且该字符不是 "(" 或者 ")"
|
||||
- depth(A + B) = max(depth(A), depth(B)),其中 A 和 B 都是 有效括号字符串
|
||||
- depth("(" + A + ")") = 1 + depth(A),其中 A 是一个 有效括号字符串
|
||||
|
||||
例如:""、"()()"、"()(()())" 都是 有效括号字符串(嵌套深度分别为 0、1、2),而 ")(" 、"(()" 都不是 有效括号字符串 。给你一个 有效括号字符串 s,返回该字符串的 s 嵌套深度 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。求一个括号字符串的嵌套深度。题目给的括号字符串都是有效的,所以不需要考虑非法的情况。扫描一遍括号字符串,遇到 `(` 可以无脑 ++,并动态维护最大值,遇到 `)` 可以无脑 - - 。最后输出最大值即可。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func maxDepth(s string) int {
|
||||
res, cur := 0, 0
|
||||
for _, c := range s {
|
||||
if c == '(' {
|
||||
cur++
|
||||
res = max(res, cur)
|
||||
} else if c == ')' {
|
||||
cur--
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
```
|
@ -0,0 +1,12 @@
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func trimMean(arr []int) float64 {
|
||||
sort.Ints(arr)
|
||||
n, sum := len(arr), 0
|
||||
for i := n / 20; i < n-(n/20); i++ {
|
||||
sum += arr[i]
|
||||
}
|
||||
return float64(sum) / float64((n - (n / 10)))
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1619 struct {
|
||||
para1619
|
||||
ans1619
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1619 struct {
|
||||
p []int
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1619 struct {
|
||||
one float64
|
||||
}
|
||||
|
||||
func Test_Problem1619(t *testing.T) {
|
||||
|
||||
qs := []question1619{
|
||||
|
||||
{
|
||||
para1619{[]int{1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3}},
|
||||
ans1619{2.00000},
|
||||
},
|
||||
|
||||
{
|
||||
para1619{[]int{6, 2, 7, 5, 1, 2, 0, 3, 10, 2, 5, 0, 5, 5, 0, 8, 7, 6, 8, 0}},
|
||||
ans1619{4.00000},
|
||||
},
|
||||
|
||||
{
|
||||
para1619{[]int{6, 0, 7, 0, 7, 5, 7, 8, 3, 4, 0, 7, 8, 1, 6, 8, 1, 1, 2, 4, 8, 1, 9, 5, 4, 3, 8, 5, 10, 8, 6, 6, 1, 0, 6, 10, 8, 2, 3, 4}},
|
||||
ans1619{4.77778},
|
||||
},
|
||||
|
||||
{
|
||||
para1619{[]int{9, 7, 8, 7, 7, 8, 4, 4, 6, 8, 8, 7, 6, 8, 8, 9, 2, 6, 0, 0, 1, 10, 8, 6, 3, 3, 5, 1, 10, 9, 0, 7, 10, 0, 10, 4, 1, 10, 6, 9, 3, 6, 0, 0, 2, 7, 0, 6, 7, 2, 9, 7, 7, 3, 0, 1, 6, 1, 10, 3}},
|
||||
ans1619{5.27778},
|
||||
},
|
||||
|
||||
{
|
||||
para1619{[]int{4, 8, 4, 10, 0, 7, 1, 3, 7, 8, 8, 3, 4, 1, 6, 2, 1, 1, 8, 0, 9, 8, 0, 3, 9, 10, 3, 10, 1, 10, 7, 3, 2, 1, 4, 9, 10, 7, 6, 4, 0, 8, 5, 1, 2, 1, 6, 2, 5, 0, 7, 10, 9, 10, 3, 7, 10, 5, 8, 5, 7, 6, 7, 6, 10, 9, 5, 10, 5, 5, 7, 2, 10, 7, 7, 8, 2, 0, 1, 1}},
|
||||
ans1619{5.29167},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1619------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1619, q.para1619
|
||||
fmt.Printf("【input】:%v 【output】:%v \n", p, trimMean(p.p))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
# [1619. Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements/)
|
||||
|
||||
## 题目
|
||||
|
||||
Given an integer array `arr`, return *the mean of the remaining integers after removing the smallest `5%` and the largest `5%` of the elements.*
|
||||
|
||||
Answers within `10-5` of the **actual answer** will be considered accepted.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]
|
||||
Output: 2.00000
|
||||
Explanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]
|
||||
Output: 4.00000
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]
|
||||
Output: 4.77778
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
|
||||
Output: 5.27778
|
||||
```
|
||||
|
||||
**Example 5:**
|
||||
|
||||
```
|
||||
Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
|
||||
Output: 5.29167
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `20 <= arr.length <= 1000`
|
||||
- `arr.length` **is a multiple** of `20`.
|
||||
- `0 <= arr[i] <= 10^5`
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个整数数组 `arr` ,请你删除最小 `5%` 的数字和最大 `5%` 的数字后,剩余数字的平均值。与 **标准答案** 误差在 `10-5` 的结果都被视为正确结果。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。先将数组排序,然后累加中间 90% 的元素,最后计算平均值。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func trimMean(arr []int) float64 {
|
||||
sort.Ints(arr)
|
||||
n, sum := len(arr), 0
|
||||
for i := n / 20; i < n-(n/20); i++ {
|
||||
sum += arr[i]
|
||||
}
|
||||
return float64(sum) / float64((n - (n / 10)))
|
||||
}
|
||||
```
|
@ -0,0 +1,16 @@
|
||||
package leetcode
|
||||
|
||||
import "strings"
|
||||
|
||||
func maxLengthBetweenEqualCharacters(s string) int {
|
||||
res := -1
|
||||
for k, v := range s {
|
||||
tmp := strings.LastIndex(s, string(v))
|
||||
if tmp > 0 {
|
||||
if res < tmp-k-1 {
|
||||
res = tmp - k - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1624 struct {
|
||||
para1624
|
||||
ans1624
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1624 struct {
|
||||
s string
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1624 struct {
|
||||
one int
|
||||
}
|
||||
|
||||
func Test_Problem1624(t *testing.T) {
|
||||
|
||||
qs := []question1624{
|
||||
|
||||
{
|
||||
para1624{"aa"},
|
||||
ans1624{0},
|
||||
},
|
||||
|
||||
{
|
||||
para1624{"abca"},
|
||||
ans1624{2},
|
||||
},
|
||||
|
||||
{
|
||||
para1624{"cbzxy"},
|
||||
ans1624{-1},
|
||||
},
|
||||
|
||||
{
|
||||
para1624{"cabbac"},
|
||||
ans1624{4},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1624------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1624, q.para1624
|
||||
fmt.Printf("【input】:%v 【output】:%v \n", p, maxLengthBetweenEqualCharacters(p.s))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
# [1624. Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters/)
|
||||
|
||||
## 题目
|
||||
|
||||
Given a string `s`, return *the length of the longest substring between two equal characters, excluding the two characters.* If there is no such substring return `-1`.
|
||||
|
||||
A **substring** is a contiguous sequence of characters within a string.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "aa"
|
||||
Output: 0
|
||||
Explanation: The optimal substring here is an empty substring between the two 'a's.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "abca"
|
||||
Output: 2
|
||||
Explanation: The optimal substring here is "bc".
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "cbzxy"
|
||||
Output: -1
|
||||
Explanation: There are no characters that appear twice in s.
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "cabbac"
|
||||
Output: 4
|
||||
Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= s.length <= 300`
|
||||
- `s` contains only lowercase English letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个字符串 s,请你返回 两个相同字符之间的最长子字符串的长度 ,计算长度时不含这两个字符。如果不存在这样的子字符串,返回 -1 。子字符串 是字符串中的一个连续字符序列。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。取每个字符,扫描一次字符串,如果在字符串中还能找到相同的字符,则返回最末尾的那个字符,计算这两个字符之间的距离。取最末尾的字符是为了让两个相同的字符距离最长。扫描字符串过程中动态维护最长长度。如果字符串中不存在 2 个相同的字符,则返回 -1 。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "strings"
|
||||
|
||||
func maxLengthBetweenEqualCharacters(s string) int {
|
||||
res := -1
|
||||
for k, v := range s {
|
||||
tmp := strings.LastIndex(s, string(v))
|
||||
if tmp > 0 {
|
||||
if res < tmp-k-1 {
|
||||
res = tmp - k - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
```
|
15
leetcode/1629.Slowest-Key/1629. Slowest Key.go
Normal file
15
leetcode/1629.Slowest-Key/1629. Slowest Key.go
Normal file
@ -0,0 +1,15 @@
|
||||
package leetcode
|
||||
|
||||
func slowestKey(releaseTimes []int, keysPressed string) byte {
|
||||
longestDuration, key := releaseTimes[0], keysPressed[0]
|
||||
for i := 1; i < len(releaseTimes); i++ {
|
||||
duration := releaseTimes[i] - releaseTimes[i-1]
|
||||
if duration > longestDuration {
|
||||
longestDuration = duration
|
||||
key = keysPressed[i]
|
||||
} else if duration == longestDuration && keysPressed[i] > key {
|
||||
key = keysPressed[i]
|
||||
}
|
||||
}
|
||||
return key
|
||||
}
|
48
leetcode/1629.Slowest-Key/1629. Slowest Key_test.go
Normal file
48
leetcode/1629.Slowest-Key/1629. Slowest Key_test.go
Normal file
@ -0,0 +1,48 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1629 struct {
|
||||
para1629
|
||||
ans1629
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1629 struct {
|
||||
releaseTimes []int
|
||||
keysPressed string
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1629 struct {
|
||||
one byte
|
||||
}
|
||||
|
||||
func Test_Problem1629(t *testing.T) {
|
||||
|
||||
qs := []question1629{
|
||||
|
||||
{
|
||||
para1629{[]int{9, 29, 49, 50}, "cbcd"},
|
||||
ans1629{'c'},
|
||||
},
|
||||
|
||||
{
|
||||
para1629{[]int{12, 23, 36, 46, 62}, "spuda"},
|
||||
ans1629{'a'},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1629------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1629, q.para1629
|
||||
fmt.Printf("【input】:%v 【output】:%c \n", p, slowestKey(p.releaseTimes, p.keysPressed))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
83
leetcode/1629.Slowest-Key/README.md
Normal file
83
leetcode/1629.Slowest-Key/README.md
Normal file
@ -0,0 +1,83 @@
|
||||
# [1629. Slowest Key](https://leetcode.com/problems/slowest-key/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
A newly designed keypad was tested, where a tester pressed a sequence of `n` keys, one at a time.
|
||||
|
||||
You are given a string `keysPressed` of length `n`, where `keysPressed[i]` was the `ith` key pressed in the testing sequence, and a sorted list `releaseTimes`, where `releaseTimes[i]` was the time the `ith` key was released. Both arrays are **0-indexed**. The `0th` key was pressed at the time `0`, and every subsequent key was pressed at the **exact** time the previous key was released.
|
||||
|
||||
The tester wants to know the key of the keypress that had the **longest duration**. The `ith` keypress had a **duration** of `releaseTimes[i] - releaseTimes[i - 1]`, and the `0th` keypress had a duration of `releaseTimes[0]`.
|
||||
|
||||
Note that the same key could have been pressed multiple times during the test, and these multiple presses of the same key **may not** have had the same **duration**.
|
||||
|
||||
*Return the key of the keypress that had the **longest duration**. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.*
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: releaseTimes = [9,29,49,50], keysPressed = "cbcd"
|
||||
Output: "c"
|
||||
Explanation: The keypresses were as follows:
|
||||
Keypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).
|
||||
Keypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).
|
||||
Keypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).
|
||||
Keypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).
|
||||
The longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.
|
||||
'c' is lexicographically larger than 'b', so the answer is 'c'.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: releaseTimes = [12,23,36,46,62], keysPressed = "spuda"
|
||||
Output: "a"
|
||||
Explanation: The keypresses were as follows:
|
||||
Keypress for 's' had a duration of 12.
|
||||
Keypress for 'p' had a duration of 23 - 12 = 11.
|
||||
Keypress for 'u' had a duration of 36 - 23 = 13.
|
||||
Keypress for 'd' had a duration of 46 - 36 = 10.
|
||||
Keypress for 'a' had a duration of 62 - 46 = 16.
|
||||
The longest of these was the keypress for 'a' with duration 16.
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `releaseTimes.length == n`
|
||||
- `keysPressed.length == n`
|
||||
- `2 <= n <= 1000`
|
||||
- `1 <= releaseTimes[i] <= 109`
|
||||
- `releaseTimes[i] < releaseTimes[i+1]`
|
||||
- `keysPressed` contains only lowercase English letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
LeetCode 设计了一款新式键盘,正在测试其可用性。测试人员将会点击一系列键(总计 n 个),每次一个。
|
||||
|
||||
给你一个长度为 n 的字符串 keysPressed ,其中 keysPressed[i] 表示测试序列中第 i 个被按下的键。releaseTimes 是一个升序排列的列表,其中 releaseTimes[i] 表示松开第 i 个键的时间。字符串和数组的 下标都从 0 开始 。第 0 个键在时间为 0 时被按下,接下来每个键都 恰好 在前一个键松开时被按下。测试人员想要找出按键 持续时间最长 的键。第 i 次按键的持续时间为 releaseTimes[i] - releaseTimes[i - 1] ,第 0 次按键的持续时间为 releaseTimes[0] 。
|
||||
|
||||
注意,测试期间,同一个键可以在不同时刻被多次按下,而每次的持续时间都可能不同。请返回按键 持续时间最长 的键,如果有多个这样的键,则返回 按字母顺序排列最大 的那个键。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 题干很长,不过还是简单题。循环扫描一遍数组,计算出每个按键的持续时间。动态更新按键最长时间的键。如果持续时间最长的有多个键,需要返回字母序最大的那一个键。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func slowestKey(releaseTimes []int, keysPressed string) byte {
|
||||
longestDuration, key := releaseTimes[0], keysPressed[0]
|
||||
for i := 1; i < len(releaseTimes); i++ {
|
||||
duration := releaseTimes[i] - releaseTimes[i-1]
|
||||
if duration > longestDuration {
|
||||
longestDuration = duration
|
||||
key = keysPressed[i]
|
||||
} else if duration == longestDuration && keysPressed[i] > key {
|
||||
key = keysPressed[i]
|
||||
}
|
||||
}
|
||||
return key
|
||||
}
|
||||
```
|
@ -0,0 +1,17 @@
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func frequencySort(nums []int) []int {
|
||||
freq := map[int]int{}
|
||||
for _, v := range nums {
|
||||
freq[v]++
|
||||
}
|
||||
sort.Slice(nums, func(i, j int) bool {
|
||||
if freq[nums[i]] == freq[nums[j]] {
|
||||
return nums[j] < nums[i]
|
||||
}
|
||||
return freq[nums[i]] < freq[nums[j]]
|
||||
})
|
||||
return nums
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1636 struct {
|
||||
para1636
|
||||
ans1636
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1636 struct {
|
||||
nums []int
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1636 struct {
|
||||
one []int
|
||||
}
|
||||
|
||||
func Test_Problem1636(t *testing.T) {
|
||||
|
||||
qs := []question1636{
|
||||
|
||||
{
|
||||
para1636{[]int{1, 1, 2, 2, 2, 3}},
|
||||
ans1636{[]int{3, 1, 1, 2, 2, 2}},
|
||||
},
|
||||
|
||||
{
|
||||
para1636{[]int{2, 3, 1, 3, 2}},
|
||||
ans1636{[]int{1, 3, 3, 2, 2}},
|
||||
},
|
||||
|
||||
{
|
||||
para1636{[]int{-1, 1, -6, 4, 5, -6, 1, 4, 1}},
|
||||
ans1636{[]int{5, -1, 4, 4, -6, -6, 1, 1, 1}},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1636------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1636, q.para1636
|
||||
fmt.Printf("【input】:%v 【output】:%v \n", p, frequencySort(p.nums))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
66
leetcode/1636.Sort-Array-by-Increasing-Frequency/README.md
Normal file
66
leetcode/1636.Sort-Array-by-Increasing-Frequency/README.md
Normal file
@ -0,0 +1,66 @@
|
||||
# [1636. Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order.
|
||||
|
||||
Return the *sorted array*.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: nums = [1,1,2,2,2,3]
|
||||
Output: [3,1,1,2,2,2]
|
||||
Explanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: nums = [2,3,1,3,2]
|
||||
Output: [1,3,3,2,2]
|
||||
Explanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: nums = [-1,1,-6,4,5,-6,1,4,1]
|
||||
Output: [5,-1,4,4,-6,-6,1,1,1]
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= nums.length <= 100`
|
||||
- `100 <= nums[i] <= 100`
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个整数数组 `nums` ,请你将数组按照每个值的频率 **升序** 排序。如果有多个值的频率相同,请你按照数值本身将它们 **降序** 排序。请你返回排序后的数组。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。先统计每个值的频率,然后按照频率从小到大排序,相同频率的按照值的大小,从大到小排序。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func frequencySort(nums []int) []int {
|
||||
freq := map[int]int{}
|
||||
for _, v := range nums {
|
||||
freq[v]++
|
||||
}
|
||||
sort.Slice(nums, func(i, j int) bool {
|
||||
if freq[nums[i]] == freq[nums[j]] {
|
||||
return nums[j] < nums[i]
|
||||
}
|
||||
return freq[nums[i]] < freq[nums[j]]
|
||||
})
|
||||
return nums
|
||||
}
|
||||
```
|
@ -5,48 +5,48 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1690 struct {
|
||||
para1690
|
||||
ans1690
|
||||
type question1696 struct {
|
||||
para1696
|
||||
ans1696
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1690 struct {
|
||||
type para1696 struct {
|
||||
nums []int
|
||||
k int
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1690 struct {
|
||||
type ans1696 struct {
|
||||
one int
|
||||
}
|
||||
|
||||
func Test_Problem1690(t *testing.T) {
|
||||
func Test_Problem1696(t *testing.T) {
|
||||
|
||||
qs := []question1690{
|
||||
|
||||
// {
|
||||
// para1690{[]int{1, -1, -2, 4, -7, 3}, 2},
|
||||
// ans1690{7},
|
||||
// },
|
||||
|
||||
// {
|
||||
// para1690{[]int{10, -5, -2, 4, 0, 3}, 3},
|
||||
// ans1690{17},
|
||||
// },
|
||||
qs := []question1696{
|
||||
|
||||
{
|
||||
para1690{[]int{1, -5, -20, 4, -1, 3, -6, -3}, 2},
|
||||
ans1690{0},
|
||||
para1696{[]int{1, -1, -2, 4, -7, 3}, 2},
|
||||
ans1696{7},
|
||||
},
|
||||
|
||||
{
|
||||
para1696{[]int{10, -5, -2, 4, 0, 3}, 3},
|
||||
ans1696{17},
|
||||
},
|
||||
|
||||
{
|
||||
para1696{[]int{1, -5, -20, 4, -1, 3, -6, -3}, 2},
|
||||
ans1696{0},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1690------------------------\n")
|
||||
fmt.Printf("------------------------Leetcode Problem 1696------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1690, q.para1690
|
||||
_, p := q.ans1696, q.para1696
|
||||
fmt.Printf("【input】:%v 【output】:%v\n", p, maxResult(p.nums, p.k))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
|
@ -0,0 +1,16 @@
|
||||
package leetcode
|
||||
|
||||
func halvesAreAlike(s string) bool {
|
||||
return numVowels(s[len(s)/2:]) == numVowels(s[:len(s)/2])
|
||||
}
|
||||
|
||||
func numVowels(x string) int {
|
||||
res := 0
|
||||
for _, c := range x {
|
||||
switch c {
|
||||
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
|
||||
res++
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question1704 struct {
|
||||
para1704
|
||||
ans1704
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para1704 struct {
|
||||
s string
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans1704 struct {
|
||||
one bool
|
||||
}
|
||||
|
||||
func Test_Problem1704(t *testing.T) {
|
||||
|
||||
qs := []question1704{
|
||||
|
||||
{
|
||||
para1704{"book"},
|
||||
ans1704{true},
|
||||
},
|
||||
|
||||
{
|
||||
para1704{"textbook"},
|
||||
ans1704{false},
|
||||
},
|
||||
|
||||
{
|
||||
para1704{"MerryChristmas"},
|
||||
ans1704{false},
|
||||
},
|
||||
|
||||
{
|
||||
para1704{"AbCdEfGh"},
|
||||
ans1704{true},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 1704------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans1704, q.para1704
|
||||
fmt.Printf("【input】:%v 【output】:%v\n", p, halvesAreAlike(p.s))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
75
leetcode/1704.Determine-if-String-Halves-Are-Alike/README.md
Normal file
75
leetcode/1704.Determine-if-String-Halves-Are-Alike/README.md
Normal file
@ -0,0 +1,75 @@
|
||||
# [1704. Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike/)
|
||||
|
||||
## 题目
|
||||
|
||||
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half.
|
||||
|
||||
Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppercase and lowercase letters.
|
||||
|
||||
Return `true` *if* `a` *and* `b` *are **alike***. Otherwise, return `false`.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "book"
|
||||
Output: true
|
||||
Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "textbook"
|
||||
Output: false
|
||||
Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
|
||||
Notice that the vowel o is counted twice.
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "MerryChristmas"
|
||||
Output: false
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "AbCdEfGh"
|
||||
Output: true
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `2 <= s.length <= 1000`
|
||||
- `s.length` is even.
|
||||
- `s` consists of **uppercase and lowercase** letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个偶数长度的字符串 s 。将其拆分成长度相同的两半,前一半为 a ,后一半为 b 。两个字符串 相似 的前提是它们都含有相同数目的元音('a','e','i','o','u','A','E','I','O','U')。注意,s 可能同时含有大写和小写字母。如果 a 和 b 相似,返回 true ;否则,返回 false 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。依题意,分别统计前半段元音字母的个数和后半段元音字母的个数,个数相同则输出 true,不同就输出 false。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func halvesAreAlike(s string) bool {
|
||||
return numVowels(s[len(s)/2:]) == numVowels(s[:len(s)/2])
|
||||
}
|
||||
|
||||
func numVowels(x string) int {
|
||||
res := 0
|
||||
for _, c := range x {
|
||||
switch c {
|
||||
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
|
||||
res++
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
```
|
@ -147,5 +147,5 @@ disablePathToLower = true
|
||||
pagerDirection= "last" # Comment sorting direction, available values are 'last' and 'first'.
|
||||
createIssueManually= true # If it is 'false', it is auto to make a Github issue when the administrators login.
|
||||
distractionFreeMode= true # Enable hot key (cmd|ctrl + enter) submit comment.
|
||||
|
||||
proxy= "https://netnr-proxy.cloudno.de/https://github.com/login/oauth/access_token"
|
||||
|
||||
|
@ -61,5 +61,5 @@ func duplicateZeros(arr []int) {
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1079.Letter-Tile-Possibilities/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1093.Statistics-from-a-Large-Sample/">下一页➡️</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1091.Shortest-Path-in-Binary-Matrix/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -0,0 +1,121 @@
|
||||
# [1091. Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
In an N by N square grid, each cell is either empty (0) or blocked (1).
|
||||
|
||||
A *clear path from top-left to bottom-right* has length `k` if and only if it is composed of cells `C_1, C_2, ..., C_k` such that:
|
||||
|
||||
- Adjacent cells `C_i` and `C_{i+1}` are connected 8-directionally (ie., they are different and share an edge or corner)
|
||||
- `C_1` is at location `(0, 0)` (ie. has value `grid[0][0]`)
|
||||
- `C_k` is at location `(N-1, N-1)` (ie. has value `grid[N-1][N-1]`)
|
||||
- If `C_i` is located at `(r, c)`, then `grid[r][c]` is empty (ie. `grid[r][c] == 0`).
|
||||
|
||||
Return the length of the shortest such clear path from top-left to bottom-right. If such a path does not exist, return -1.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: [[0,1],[1,0]]
|
||||
Output: 2
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: [[0,0,0],[1,1,0],[1,1,0]]
|
||||
Output: 4
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Note:**
|
||||
|
||||
1. `1 <= grid.length == grid[0].length <= 100`
|
||||
2. `grid[r][c]` is `0` or `1`
|
||||
|
||||
## 题目大意
|
||||
|
||||
在一个 N × N 的方形网格中,每个单元格有两种状态:空(0)或者阻塞(1)。一条从左上角到右下角、长度为 k 的畅通路径,由满足下述条件的单元格 C_1, C_2, ..., C_k 组成:
|
||||
|
||||
- 相邻单元格 C_i 和 C_{i+1} 在八个方向之一上连通(此时,C_i 和 C_{i+1} 不同且共享边或角)
|
||||
- C_1 位于 (0, 0)(即,值为 grid[0][0])
|
||||
- C_k 位于 (N-1, N-1)(即,值为 grid[N-1][N-1])
|
||||
- 如果 C_i 位于 (r, c),则 grid[r][c] 为空(即,grid[r][c] == 0)
|
||||
|
||||
返回这条从左上角到右下角的最短畅通路径的长度。如果不存在这样的路径,返回 -1 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 这一题是简单的找最短路径。利用 BFS 从左上角逐步扩展到右下角,便可以很容易求解。注意每轮扩展需要考虑 8 个方向。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
var dir = [][]int{
|
||||
{-1, -1},
|
||||
{-1, 0},
|
||||
{-1, 1},
|
||||
{0, 1},
|
||||
{0, -1},
|
||||
{1, -1},
|
||||
{1, 0},
|
||||
{1, 1},
|
||||
}
|
||||
|
||||
func shortestPathBinaryMatrix(grid [][]int) int {
|
||||
visited := make([][]bool, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
visited = append(visited, make([]bool, len(grid[0])))
|
||||
}
|
||||
dis := make([][]int, 0)
|
||||
for range make([]int, len(grid)) {
|
||||
dis = append(dis, make([]int, len(grid[0])))
|
||||
}
|
||||
if grid[0][0] == 1 {
|
||||
return -1
|
||||
}
|
||||
if len(grid) == 1 && len(grid[0]) == 1 {
|
||||
return 1
|
||||
}
|
||||
|
||||
queue := []int{0}
|
||||
visited[0][0], dis[0][0] = true, 1
|
||||
for len(queue) > 0 {
|
||||
cur := queue[0]
|
||||
queue = queue[1:]
|
||||
curx, cury := cur/len(grid[0]), cur%len(grid[0])
|
||||
for d := 0; d < 8; d++ {
|
||||
nextx := curx + dir[d][0]
|
||||
nexty := cury + dir[d][1]
|
||||
if isInBoard(grid, nextx, nexty) && !visited[nextx][nexty] && grid[nextx][nexty] == 0 {
|
||||
queue = append(queue, nextx*len(grid[0])+nexty)
|
||||
visited[nextx][nexty] = true
|
||||
dis[nextx][nexty] = dis[curx][cury] + 1
|
||||
if nextx == len(grid)-1 && nexty == len(grid[0])-1 {
|
||||
return dis[nextx][nexty]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func isInBoard(board [][]int, x, y int) bool {
|
||||
return x >= 0 && x < len(board) && y >= 0 && y < len(board[0])
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1089.Duplicate-Zeros/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1093.Statistics-from-a-Large-Sample/">下一页➡️</a></p>
|
||||
</div>
|
@ -97,6 +97,6 @@ func sampleStats(count []int) []float64 {
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1089.Duplicate-Zeros/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1000~1099/1091.Shortest-Path-in-Binary-Matrix/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1100~1199/1105.Filling-Bookcase-Shelves/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -106,5 +106,5 @@ func maxNumEdgesToRemove(n int, edges [][]int) int {
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1573.Number-of-Ways-to-Split-a-String/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort/">下一页➡️</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -0,0 +1,109 @@
|
||||
# [1614. Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/)
|
||||
|
||||
## 题目
|
||||
|
||||
A string is a **valid parentheses string** (denoted **VPS**) if it meets one of the following:
|
||||
|
||||
- It is an empty string `""`, or a single character not equal to `"("` or `")"`,
|
||||
- It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are **VPS**'s, or
|
||||
- It can be written as `(A)`, where `A` is a **VPS**.
|
||||
|
||||
We can similarly define the **nesting depth** `depth(S)` of any VPS `S` as follows:
|
||||
|
||||
- `depth("") = 0`
|
||||
- `depth(C) = 0`, where `C` is a string with a single character not equal to `"("` or `")"`.
|
||||
- `depth(A + B) = max(depth(A), depth(B))`, where `A` and `B` are **VPS**'s.
|
||||
- `depth("(" + A + ")") = 1 + depth(A)`, where `A` is a **VPS**.
|
||||
|
||||
For example, `""`, `"()()"`, and `"()(()())"` are **VPS**'s (with nesting depths 0, 1, and 2), and `")("` and `"(()"` are not **VPS**'s.
|
||||
|
||||
Given a **VPS** represented as string `s`, return *the **nesting depth** of* `s`.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "(1+(2*3)+((8)/4))+1"
|
||||
Output: 3
|
||||
Explanation: Digit 8 is inside of 3 nested parentheses in the string.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "(1)+((2))+(((3)))"
|
||||
Output: 3
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "1+(2*3)/(2-1)"
|
||||
Output: 1
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "1"
|
||||
Output: 0
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= s.length <= 100`
|
||||
- `s` consists of digits `0-9` and characters `'+'`, `'-'`, `'*'`, `'/'`, `'('`, and `')'`.
|
||||
- It is guaranteed that parentheses expression `s` is a **VPS**.
|
||||
|
||||
## 题目大意
|
||||
|
||||
如果字符串满足以下条件之一,则可以称之为 有效括号字符串(valid parentheses string,可以简写为 VPS):
|
||||
|
||||
- 字符串是一个空字符串 "",或者是一个不为 "(" 或 ")" 的单字符。
|
||||
- 字符串可以写为 AB(A 与 B 字符串连接),其中 A 和 B 都是 有效括号字符串 。
|
||||
- 字符串可以写为 (A),其中 A 是一个 有效括号字符串 。
|
||||
|
||||
类似地,可以定义任何有效括号字符串 S 的 嵌套深度 depth(S):
|
||||
|
||||
- depth("") = 0
|
||||
- depth(C) = 0,其中 C 是单个字符的字符串,且该字符不是 "(" 或者 ")"
|
||||
- depth(A + B) = max(depth(A), depth(B)),其中 A 和 B 都是 有效括号字符串
|
||||
- depth("(" + A + ")") = 1 + depth(A),其中 A 是一个 有效括号字符串
|
||||
|
||||
例如:""、"()()"、"()(()())" 都是 有效括号字符串(嵌套深度分别为 0、1、2),而 ")(" 、"(()" 都不是 有效括号字符串 。给你一个 有效括号字符串 s,返回该字符串的 s 嵌套深度 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。求一个括号字符串的嵌套深度。题目给的括号字符串都是有效的,所以不需要考虑非法的情况。扫描一遍括号字符串,遇到 `(` 可以无脑 ++,并动态维护最大值,遇到 `)` 可以无脑 - - 。最后输出最大值即可。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func maxDepth(s string) int {
|
||||
res, cur := 0, 0
|
||||
for _, c := range s {
|
||||
if c == '(' {
|
||||
cur++
|
||||
res = max(res, cur)
|
||||
} else if c == ')' {
|
||||
cur--
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements/">下一页➡️</a></p>
|
||||
</div>
|
@ -0,0 +1,81 @@
|
||||
# [1619. Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements/)
|
||||
|
||||
## 题目
|
||||
|
||||
Given an integer array `arr`, return *the mean of the remaining integers after removing the smallest `5%` and the largest `5%` of the elements.*
|
||||
|
||||
Answers within `10-5` of the **actual answer** will be considered accepted.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]
|
||||
Output: 2.00000
|
||||
Explanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]
|
||||
Output: 4.00000
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]
|
||||
Output: 4.77778
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
|
||||
Output: 5.27778
|
||||
```
|
||||
|
||||
**Example 5:**
|
||||
|
||||
```
|
||||
Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
|
||||
Output: 5.29167
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `20 <= arr.length <= 1000`
|
||||
- `arr.length` **is a multiple** of `20`.
|
||||
- `0 <= arr[i] <= 10^5`
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个整数数组 `arr` ,请你删除最小 `5%` 的数字和最大 `5%` 的数字后,剩余数字的平均值。与 **标准答案** 误差在 `10-5` 的结果都被视为正确结果。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。先将数组排序,然后累加中间 90% 的元素,最后计算平均值。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func trimMean(arr []int) float64 {
|
||||
sort.Ints(arr)
|
||||
n, sum := len(arr), 0
|
||||
for i := n / 20; i < n-(n/20); i++ {
|
||||
sum += arr[i]
|
||||
}
|
||||
return float64(sum) / float64((n - (n / 10)))
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1624.Largest-Substring-Between-Two-Equal-Characters/">下一页➡️</a></p>
|
||||
</div>
|
@ -0,0 +1,80 @@
|
||||
# [1624. Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters/)
|
||||
|
||||
## 题目
|
||||
|
||||
Given a string `s`, return *the length of the longest substring between two equal characters, excluding the two characters.* If there is no such substring return `-1`.
|
||||
|
||||
A **substring** is a contiguous sequence of characters within a string.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "aa"
|
||||
Output: 0
|
||||
Explanation: The optimal substring here is an empty substring between the two 'a's.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "abca"
|
||||
Output: 2
|
||||
Explanation: The optimal substring here is "bc".
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "cbzxy"
|
||||
Output: -1
|
||||
Explanation: There are no characters that appear twice in s.
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "cabbac"
|
||||
Output: 4
|
||||
Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= s.length <= 300`
|
||||
- `s` contains only lowercase English letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个字符串 s,请你返回 两个相同字符之间的最长子字符串的长度 ,计算长度时不含这两个字符。如果不存在这样的子字符串,返回 -1 。子字符串 是字符串中的一个连续字符序列。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。取每个字符,扫描一次字符串,如果在字符串中还能找到相同的字符,则返回最末尾的那个字符,计算这两个字符之间的距离。取最末尾的字符是为了让两个相同的字符距离最长。扫描字符串过程中动态维护最长长度。如果字符串中不存在 2 个相同的字符,则返回 -1 。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "strings"
|
||||
|
||||
func maxLengthBetweenEqualCharacters(s string) int {
|
||||
res := -1
|
||||
for k, v := range s {
|
||||
tmp := strings.LastIndex(s, string(v))
|
||||
if tmp > 0 {
|
||||
if res < tmp-k-1 {
|
||||
res = tmp - k - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1629.Slowest-Key/">下一页➡️</a></p>
|
||||
</div>
|
90
website/content/ChapterFour/1600~1699/1629.Slowest-Key.md
Normal file
90
website/content/ChapterFour/1600~1699/1629.Slowest-Key.md
Normal file
@ -0,0 +1,90 @@
|
||||
# [1629. Slowest Key](https://leetcode.com/problems/slowest-key/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
A newly designed keypad was tested, where a tester pressed a sequence of `n` keys, one at a time.
|
||||
|
||||
You are given a string `keysPressed` of length `n`, where `keysPressed[i]` was the `ith` key pressed in the testing sequence, and a sorted list `releaseTimes`, where `releaseTimes[i]` was the time the `ith` key was released. Both arrays are **0-indexed**. The `0th` key was pressed at the time `0`, and every subsequent key was pressed at the **exact** time the previous key was released.
|
||||
|
||||
The tester wants to know the key of the keypress that had the **longest duration**. The `ith` keypress had a **duration** of `releaseTimes[i] - releaseTimes[i - 1]`, and the `0th` keypress had a duration of `releaseTimes[0]`.
|
||||
|
||||
Note that the same key could have been pressed multiple times during the test, and these multiple presses of the same key **may not** have had the same **duration**.
|
||||
|
||||
*Return the key of the keypress that had the **longest duration**. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.*
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: releaseTimes = [9,29,49,50], keysPressed = "cbcd"
|
||||
Output: "c"
|
||||
Explanation: The keypresses were as follows:
|
||||
Keypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).
|
||||
Keypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).
|
||||
Keypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).
|
||||
Keypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).
|
||||
The longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.
|
||||
'c' is lexicographically larger than 'b', so the answer is 'c'.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: releaseTimes = [12,23,36,46,62], keysPressed = "spuda"
|
||||
Output: "a"
|
||||
Explanation: The keypresses were as follows:
|
||||
Keypress for 's' had a duration of 12.
|
||||
Keypress for 'p' had a duration of 23 - 12 = 11.
|
||||
Keypress for 'u' had a duration of 36 - 23 = 13.
|
||||
Keypress for 'd' had a duration of 46 - 36 = 10.
|
||||
Keypress for 'a' had a duration of 62 - 46 = 16.
|
||||
The longest of these was the keypress for 'a' with duration 16.
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `releaseTimes.length == n`
|
||||
- `keysPressed.length == n`
|
||||
- `2 <= n <= 1000`
|
||||
- `1 <= releaseTimes[i] <= 109`
|
||||
- `releaseTimes[i] < releaseTimes[i+1]`
|
||||
- `keysPressed` contains only lowercase English letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
LeetCode 设计了一款新式键盘,正在测试其可用性。测试人员将会点击一系列键(总计 n 个),每次一个。
|
||||
|
||||
给你一个长度为 n 的字符串 keysPressed ,其中 keysPressed[i] 表示测试序列中第 i 个被按下的键。releaseTimes 是一个升序排列的列表,其中 releaseTimes[i] 表示松开第 i 个键的时间。字符串和数组的 下标都从 0 开始 。第 0 个键在时间为 0 时被按下,接下来每个键都 恰好 在前一个键松开时被按下。测试人员想要找出按键 持续时间最长 的键。第 i 次按键的持续时间为 releaseTimes[i] - releaseTimes[i - 1] ,第 0 次按键的持续时间为 releaseTimes[0] 。
|
||||
|
||||
注意,测试期间,同一个键可以在不同时刻被多次按下,而每次的持续时间都可能不同。请返回按键 持续时间最长 的键,如果有多个这样的键,则返回 按字母顺序排列最大 的那个键。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 题干很长,不过还是简单题。循环扫描一遍数组,计算出每个按键的持续时间。动态更新按键最长时间的键。如果持续时间最长的有多个键,需要返回字母序最大的那一个键。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func slowestKey(releaseTimes []int, keysPressed string) byte {
|
||||
longestDuration, key := releaseTimes[0], keysPressed[0]
|
||||
for i := 1; i < len(releaseTimes); i++ {
|
||||
duration := releaseTimes[i] - releaseTimes[i-1]
|
||||
if duration > longestDuration {
|
||||
longestDuration = duration
|
||||
key = keysPressed[i]
|
||||
} else if duration == longestDuration && keysPressed[i] > key {
|
||||
key = keysPressed[i]
|
||||
}
|
||||
}
|
||||
return key
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1624.Largest-Substring-Between-Two-Equal-Characters/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort/">下一页➡️</a></p>
|
||||
</div>
|
@ -172,6 +172,6 @@ type edge struct {
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1500~1599/1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation/">下一页➡️</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1629.Slowest-Key/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -0,0 +1,73 @@
|
||||
# [1636. Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order.
|
||||
|
||||
Return the *sorted array*.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: nums = [1,1,2,2,2,3]
|
||||
Output: [3,1,1,2,2,2]
|
||||
Explanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: nums = [2,3,1,3,2]
|
||||
Output: [1,3,3,2,2]
|
||||
Explanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: nums = [-1,1,-6,4,5,-6,1,4,1]
|
||||
Output: [5,-1,4,4,-6,-6,1,1,1]
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `1 <= nums.length <= 100`
|
||||
- `100 <= nums[i] <= 100`
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个整数数组 `nums` ,请你将数组按照每个值的频率 **升序** 排序。如果有多个值的频率相同,请你按照数值本身将它们 **降序** 排序。请你返回排序后的数组。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。先统计每个值的频率,然后按照频率从小到大排序,相同频率的按照值的大小,从大到小排序。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
import "sort"
|
||||
|
||||
func frequencySort(nums []int) []int {
|
||||
freq := map[int]int{}
|
||||
for _, v := range nums {
|
||||
freq[v]++
|
||||
}
|
||||
sort.Slice(nums, func(i, j int) bool {
|
||||
if freq[nums[i]] == freq[nums[j]] {
|
||||
return nums[j] < nums[i]
|
||||
}
|
||||
return freq[nums[i]] < freq[nums[j]]
|
||||
})
|
||||
return nums
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation/">下一页➡️</a></p>
|
||||
</div>
|
@ -97,6 +97,6 @@ func canFormArray(arr []int, pieces [][]int) bool {
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1631.Path-With-Minimum-Effort/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -109,6 +109,10 @@ func max(a, b int) int {
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1695.Maximum-Erasure-Value/">⬅️上一页</a></p>
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1695.Maximum-Erasure-Value/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -0,0 +1,80 @@
|
||||
# [1704. Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike/)
|
||||
|
||||
## 题目
|
||||
|
||||
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half.
|
||||
|
||||
Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppercase and lowercase letters.
|
||||
|
||||
Return `true` *if* `a` *and* `b` *are **alike***. Otherwise, return `false`.
|
||||
|
||||
**Example 1:**
|
||||
|
||||
```
|
||||
Input: s = "book"
|
||||
Output: true
|
||||
Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
|
||||
```
|
||||
|
||||
**Example 2:**
|
||||
|
||||
```
|
||||
Input: s = "textbook"
|
||||
Output: false
|
||||
Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
|
||||
Notice that the vowel o is counted twice.
|
||||
```
|
||||
|
||||
**Example 3:**
|
||||
|
||||
```
|
||||
Input: s = "MerryChristmas"
|
||||
Output: false
|
||||
```
|
||||
|
||||
**Example 4:**
|
||||
|
||||
```
|
||||
Input: s = "AbCdEfGh"
|
||||
Output: true
|
||||
```
|
||||
|
||||
**Constraints:**
|
||||
|
||||
- `2 <= s.length <= 1000`
|
||||
- `s.length` is even.
|
||||
- `s` consists of **uppercase and lowercase** letters.
|
||||
|
||||
## 题目大意
|
||||
|
||||
给你一个偶数长度的字符串 s 。将其拆分成长度相同的两半,前一半为 a ,后一半为 b 。两个字符串 相似 的前提是它们都含有相同数目的元音('a','e','i','o','u','A','E','I','O','U')。注意,s 可能同时含有大写和小写字母。如果 a 和 b 相似,返回 true ;否则,返回 false 。
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 简单题。依题意,分别统计前半段元音字母的个数和后半段元音字母的个数,个数相同则输出 true,不同就输出 false。
|
||||
|
||||
## 代码
|
||||
|
||||
```go
|
||||
package leetcode
|
||||
|
||||
func halvesAreAlike(s string) bool {
|
||||
return numVowels(s[len(s)/2:]) == numVowels(s[:len(s)/2])
|
||||
}
|
||||
|
||||
func numVowels(x string) int {
|
||||
res := 0
|
||||
for _, c := range x {
|
||||
switch c {
|
||||
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
|
||||
res++
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/1600~1699/1696.Jump-Game-VI/">⬅️上一页</a></p>
|
||||
|
4
website/content/ChapterFour/1700~1799/_index.md
Normal file
4
website/content/ChapterFour/1700~1799/_index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
bookCollapseSection: true
|
||||
weight: 20
|
||||
---
|
@ -106,7 +106,7 @@ weight: 1
|
||||
|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%|
|
||||
|0977|Squares of a Sorted Array|[Go]({{< relref "/ChapterFour/0900~0999/0977.Squares-of-a-Sorted-Array.md" >}})|Easy| O(n)| O(1)||72.1%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium||||46.6%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium||||46.7%|
|
||||
|0985|Sum of Even Numbers After Queries|[Go]({{< relref "/ChapterFour/0900~0999/0985.Sum-of-Even-Numbers-After-Queries.md" >}})|Easy||||60.7%|
|
||||
|0989|Add to Array-Form of Integer|[Go]({{< relref "/ChapterFour/0900~0999/0989.Add-to-Array-Form-of-Integer.md" >}})|Easy||||44.8%|
|
||||
|0999|Available Captures for Rook|[Go]({{< relref "/ChapterFour/0900~0999/0999.Available-Captures-for-Rook.md" >}})|Easy||||67.7%|
|
||||
@ -125,7 +125,7 @@ weight: 1
|
||||
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.6%|
|
||||
|1184|Distance Between Bus Stops|[Go]({{< relref "/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md" >}})|Easy||||54.1%|
|
||||
|1185|Day of the Week|[Go]({{< relref "/ChapterFour/1100~1199/1185.Day-of-the-Week.md" >}})|Easy||||61.6%|
|
||||
|1200|Minimum Absolute Difference|[Go]({{< relref "/ChapterFour/1200~1299/1200.Minimum-Absolute-Difference.md" >}})|Easy||||66.9%|
|
||||
|1200|Minimum Absolute Difference|[Go]({{< relref "/ChapterFour/1200~1299/1200.Minimum-Absolute-Difference.md" >}})|Easy||||67.0%|
|
||||
|1202|Smallest String With Swaps|[Go]({{< relref "/ChapterFour/1200~1299/1202.Smallest-String-With-Swaps.md" >}})|Medium||||48.7%|
|
||||
|1208|Get Equal Substrings Within Budget|[Go]({{< relref "/ChapterFour/1200~1299/1208.Get-Equal-Substrings-Within-Budget.md" >}})|Medium||||43.9%|
|
||||
|1217|Minimum Cost to Move Chips to The Same Position|[Go]({{< relref "/ChapterFour/1200~1299/1217.Minimum-Cost-to-Move-Chips-to-The-Same-Position.md" >}})|Easy||||71.2%|
|
||||
@ -151,10 +151,13 @@ 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%|
|
||||
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.2%|
|
||||
|1646|Get Maximum in Generated Array|[Go]({{< relref "/ChapterFour/1600~1699/1646.Get-Maximum-in-Generated-Array.md" >}})|Easy||||53.5%|
|
||||
|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%|
|
||||
|1652|Defuse the Bomb|[Go]({{< relref "/ChapterFour/1600~1699/1652.Defuse-the-Bomb.md" >}})|Easy||||63.0%|
|
||||
|1656|Design an Ordered Stream|[Go]({{< relref "/ChapterFour/1600~1699/1656.Design-an-Ordered-Stream.md" >}})|Easy||||82.2%|
|
||||
|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%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
@ -101,7 +101,7 @@ func updateMatrix_BFS(matrix [][]int) [][]int {
|
||||
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance |
|
||||
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
|
||||
|0017|Letter Combinations of a Phone Number|[Go]({{< relref "/ChapterFour/0001~0099/0017.Letter-Combinations-of-a-Phone-Number.md" >}})|Medium| O(log n)| O(1)||49.0%|
|
||||
|0022|Generate Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0022.Generate-Parentheses.md" >}})|Medium| O(log n)| O(1)||65.1%|
|
||||
|0022|Generate Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0022.Generate-Parentheses.md" >}})|Medium| O(log n)| O(1)||65.2%|
|
||||
|0037|Sudoku Solver|[Go]({{< relref "/ChapterFour/0001~0099/0037.Sudoku-Solver.md" >}})|Hard| O(n^2)| O(n^2)|❤️|46.4%|
|
||||
|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%|
|
||||
|
@ -144,7 +144,7 @@ func peakIndexInMountainArray(A []int) int {
|
||||
|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%|
|
||||
|0162|Find Peak Element|[Go]({{< relref "/ChapterFour/0100~0199/0162.Find-Peak-Element.md" >}})|Medium||||43.9%|
|
||||
|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.2%|
|
||||
|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%|
|
||||
|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%|
|
||||
@ -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.4%|
|
||||
|0441|Arranging Coins|[Go]({{< relref "/ChapterFour/0400~0499/0441.Arranging-Coins.md" >}})|Easy||||42.3%|
|
||||
|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%|
|
||||
@ -181,10 +181,10 @@ func peakIndexInMountainArray(A []int) int {
|
||||
|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.4%|
|
||||
|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%|
|
||||
|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.3%|
|
||||
|0911|Online Election|[Go]({{< relref "/ChapterFour/0900~0999/0911.Online-Election.md" >}})|Medium||||51.2%|
|
||||
|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%|
|
||||
@ -192,7 +192,7 @@ func peakIndexInMountainArray(A []int) int {
|
||||
|1157|Online Majority Element In Subarray|[Go]({{< relref "/ChapterFour/1100~1199/1157.Online-Majority-Element-In-Subarray.md" >}})|Hard||||39.6%|
|
||||
|1170|Compare Strings by Frequency of the Smallest Character|[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})|Medium||||59.6%|
|
||||
|1201|Ugly Number III|[Go]({{< relref "/ChapterFour/1200~1299/1201.Ugly-Number-III.md" >}})|Medium||||26.4%|
|
||||
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.3%|
|
||||
|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%|
|
||||
|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%|
|
||||
|
@ -61,7 +61,7 @@ X & ~X = 0
|
||||
|0371|Sum of Two Integers|[Go]({{< relref "/ChapterFour/0300~0399/0371.Sum-of-Two-Integers.md" >}})|Medium| O(n)| O(1)||50.6%|
|
||||
|0389|Find the Difference|[Go]({{< relref "/ChapterFour/0300~0399/0389.Find-the-Difference.md" >}})|Easy| O(n)| O(1)||57.8%|
|
||||
|0393|UTF-8 Validation|[Go]({{< relref "/ChapterFour/0300~0399/0393.UTF-8-Validation.md" >}})|Medium| O(n)| O(1)||38.0%|
|
||||
|0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium| O(n)| O(1)||33.4%|
|
||||
|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%|
|
||||
|
@ -18,7 +18,7 @@ weight: 10
|
||||
|0127|Word Ladder|[Go]({{< relref "/ChapterFour/0100~0199/0127.Word-Ladder.md" >}})|Hard| O(n)| O(n)||31.7%|
|
||||
|0130|Surrounded Regions|[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})|Medium||||29.3%|
|
||||
|0199|Binary Tree Right Side View|[Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}})|Medium| O(n)| O(1)||56.3%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(n^2)| O(n^2)||48.9%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(n^2)| O(n^2)||49.0%|
|
||||
|0207|Course Schedule|[Go]({{< relref "/ChapterFour/0200~0299/0207.Course-Schedule.md" >}})|Medium| O(n^2)| O(n^2)||44.3%|
|
||||
|0210|Course Schedule II|[Go]({{< relref "/ChapterFour/0200~0299/0210.Course-Schedule-II.md" >}})|Medium| O(n^2)| O(n^2)||42.5%|
|
||||
|0513|Find Bottom Left Tree Value|[Go]({{< relref "/ChapterFour/0500~0599/0513.Find-Bottom-Left-Tree-Value.md" >}})|Medium||||62.5%|
|
||||
@ -31,9 +31,10 @@ weight: 10
|
||||
|0864|Shortest Path to Get All Keys|[Go]({{< relref "/ChapterFour/0800~0899/0864.Shortest-Path-to-Get-All-Keys.md" >}})|Hard||||41.9%|
|
||||
|0987|Vertical Order Traversal of a Binary Tree|[Go]({{< relref "/ChapterFour/0900~0999/0987.Vertical-Order-Traversal-of-a-Binary-Tree.md" >}})|Hard||||38.7%|
|
||||
|0993|Cousins in Binary Tree|[Go]({{< relref "/ChapterFour/0900~0999/0993.Cousins-in-Binary-Tree.md" >}})|Easy| O(n)| O(1)||52.3%|
|
||||
|1091|Shortest Path in Binary Matrix|[Go]({{< relref "/ChapterFour/1000~1099/1091.Shortest-Path-in-Binary-Matrix.md" >}})|Medium||||39.8%|
|
||||
|1306|Jump Game III|[Go]({{< relref "/ChapterFour/1300~1399/1306.Jump-Game-III.md" >}})|Medium||||62.6%|
|
||||
|1319|Number of Operations to Make Network Connected|[Go]({{< relref "/ChapterFour/1300~1399/1319.Number-of-Operations-to-Make-Network-Connected.md" >}})|Medium||||55.4%|
|
||||
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.1%|
|
||||
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.0%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ weight: 9
|
||||
|0130|Surrounded Regions|[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})|Medium||||29.3%|
|
||||
|0131|Palindrome Partitioning|[Go]({{< relref "/ChapterFour/0100~0199/0131.Palindrome-Partitioning.md" >}})|Medium||||51.8%|
|
||||
|0199|Binary Tree Right Side View|[Go]({{< relref "/ChapterFour/0100~0199/0199.Binary-Tree-Right-Side-View.md" >}})|Medium| O(n)| O(1)||56.3%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(n^2)| O(n^2)||48.9%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(n^2)| O(n^2)||49.0%|
|
||||
|0207|Course Schedule|[Go]({{< relref "/ChapterFour/0200~0299/0207.Course-Schedule.md" >}})|Medium| O(n^2)| O(n^2)||44.3%|
|
||||
|0210|Course Schedule II|[Go]({{< relref "/ChapterFour/0200~0299/0210.Course-Schedule-II.md" >}})|Medium| O(n^2)| O(n^2)||42.5%|
|
||||
|0211|Design Add and Search Words Data Structure|[Go]({{< relref "/ChapterFour/0200~0299/0211.Design-Add-and-Search-Words-Data-Structure.md" >}})|Medium||||40.1%|
|
||||
@ -64,7 +64,7 @@ weight: 9
|
||||
|0863|All Nodes Distance K in Binary Tree|[Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}})|Medium||||57.8%|
|
||||
|0872|Leaf-Similar Trees|[Go]({{< relref "/ChapterFour/0800~0899/0872.Leaf-Similar-Trees.md" >}})|Easy||||64.6%|
|
||||
|0897|Increasing Order Search Tree|[Go]({{< relref "/ChapterFour/0800~0899/0897.Increasing-Order-Search-Tree.md" >}})|Easy||||74.5%|
|
||||
|0924|Minimize Malware Spread|[Go]({{< relref "/ChapterFour/0900~0999/0924.Minimize-Malware-Spread.md" >}})|Hard||||41.8%|
|
||||
|0924|Minimize Malware Spread|[Go]({{< relref "/ChapterFour/0900~0999/0924.Minimize-Malware-Spread.md" >}})|Hard||||41.9%|
|
||||
|0928|Minimize Malware Spread II|[Go]({{< relref "/ChapterFour/0900~0999/0928.Minimize-Malware-Spread-II.md" >}})|Hard||||41.2%|
|
||||
|0947|Most Stones Removed with Same Row or Column|[Go]({{< relref "/ChapterFour/0900~0999/0947.Most-Stones-Removed-with-Same-Row-or-Column.md" >}})|Medium||||55.4%|
|
||||
|0959|Regions Cut By Slashes|[Go]({{< relref "/ChapterFour/0900~0999/0959.Regions-Cut-By-Slashes.md" >}})|Medium||||67.1%|
|
||||
|
@ -22,7 +22,7 @@ weight: 7
|
||||
|0121|Best Time to Buy and Sell Stock|[Go]({{< relref "/ChapterFour/0100~0199/0121.Best-Time-to-Buy-and-Sell-Stock.md" >}})|Easy| O(n)| O(1)||51.5%|
|
||||
|0131|Palindrome Partitioning|[Go]({{< relref "/ChapterFour/0100~0199/0131.Palindrome-Partitioning.md" >}})|Medium||||51.8%|
|
||||
|0152|Maximum Product Subarray|[Go]({{< relref "/ChapterFour/0100~0199/0152.Maximum-Product-Subarray.md" >}})|Medium| O(n)| O(1)||32.7%|
|
||||
|0174|Dungeon Game|[Go]({{< relref "/ChapterFour/0100~0199/0174.Dungeon-Game.md" >}})|Hard||||33.2%|
|
||||
|0174|Dungeon Game|[Go]({{< relref "/ChapterFour/0100~0199/0174.Dungeon-Game.md" >}})|Hard||||33.3%|
|
||||
|0198|House Robber|[Go]({{< relref "/ChapterFour/0100~0199/0198.House-Robber.md" >}})|Medium| O(n)| O(n)||42.8%|
|
||||
|0213|House Robber II|[Go]({{< relref "/ChapterFour/0200~0299/0213.House-Robber-II.md" >}})|Medium| O(n)| O(n)||37.5%|
|
||||
|0300|Longest Increasing Subsequence|[Go]({{< relref "/ChapterFour/0300~0399/0300.Longest-Increasing-Subsequence.md" >}})|Medium| O(n log n)| O(n)||43.9%|
|
||||
@ -48,21 +48,21 @@ weight: 7
|
||||
|0898|Bitwise ORs of Subarrays|[Go]({{< relref "/ChapterFour/0800~0899/0898.Bitwise-ORs-of-Subarrays.md" >}})|Medium||||34.1%|
|
||||
|0920|Number of Music Playlists|[Go]({{< relref "/ChapterFour/0900~0999/0920.Number-of-Music-Playlists.md" >}})|Hard||||47.8%|
|
||||
|0968|Binary Tree Cameras|[Go]({{< relref "/ChapterFour/0900~0999/0968.Binary-Tree-Cameras.md" >}})|Hard||||38.7%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium||||46.6%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium||||46.7%|
|
||||
|1025|Divisor Game|[Go]({{< relref "/ChapterFour/1000~1099/1025.Divisor-Game.md" >}})|Easy| O(1)| O(1)||66.2%|
|
||||
|1049|Last Stone Weight II|[Go]({{< relref "/ChapterFour/1000~1099/1049.Last-Stone-Weight-II.md" >}})|Medium||||45.2%|
|
||||
|1074|Number of Submatrices That Sum to Target|[Go]({{< relref "/ChapterFour/1000~1099/1074.Number-of-Submatrices-That-Sum-to-Target.md" >}})|Hard||||61.7%|
|
||||
|1105|Filling Bookcase Shelves|[Go]({{< relref "/ChapterFour/1100~1199/1105.Filling-Bookcase-Shelves.md" >}})|Medium||||57.5%|
|
||||
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.3%|
|
||||
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.4%|
|
||||
|1423|Maximum Points You Can Obtain from Cards|[Go]({{< relref "/ChapterFour/1400~1499/1423.Maximum-Points-You-Can-Obtain-from-Cards.md" >}})|Medium||||46.6%|
|
||||
|1463|Cherry Pickup II|[Go]({{< relref "/ChapterFour/1400~1499/1463.Cherry-Pickup-II.md" >}})|Hard||||69.3%|
|
||||
|1641|Count Sorted Vowel Strings|[Go]({{< relref "/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings.md" >}})|Medium||||76.9%|
|
||||
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.1%|
|
||||
|1654|Minimum Jumps to Reach Home|[Go]({{< relref "/ChapterFour/1600~1699/1654.Minimum-Jumps-to-Reach-Home.md" >}})|Medium||||26.0%|
|
||||
|1655|Distribute Repeating Integers|[Go]({{< relref "/ChapterFour/1600~1699/1655.Distribute-Repeating-Integers.md" >}})|Hard||||40.3%|
|
||||
|1659|Maximize Grid Happiness|[Go]({{< relref "/ChapterFour/1600~1699/1659.Maximize-Grid-Happiness.md" >}})|Hard||||35.3%|
|
||||
|1664|Ways to Make a Fair Array|[Go]({{< relref "/ChapterFour/1600~1699/1664.Ways-to-Make-a-Fair-Array.md" >}})|Medium||||60.6%|
|
||||
|1664|Ways to Make a Fair Array|[Go]({{< relref "/ChapterFour/1600~1699/1664.Ways-to-Make-a-Fair-Array.md" >}})|Medium||||61.5%|
|
||||
|1690|Stone Game VII|[Go]({{< relref "/ChapterFour/1600~1699/1690.Stone-Game-VII.md" >}})|Medium||||47.6%|
|
||||
|1691|Maximum Height by Stacking Cuboids|[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})|Hard||||49.9%|
|
||||
|1691|Maximum Height by Stacking Cuboids|[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})|Hard||||50.0%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@ weight: 13
|
||||
|0001|Two Sum|[Go]({{< relref "/ChapterFour/0001~0099/0001.Two-Sum.md" >}})|Easy| O(n)| O(n)||46.4%|
|
||||
|0003|Longest Substring Without Repeating Characters|[Go]({{< relref "/ChapterFour/0001~0099/0003.Longest-Substring-Without-Repeating-Characters.md" >}})|Medium| O(n)| O(1)|❤️|31.4%|
|
||||
|0018|4Sum|[Go]({{< relref "/ChapterFour/0001~0099/0018.4Sum.md" >}})|Medium| O(n^3)| O(n^2)|❤️|34.8%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|
||||
|0036|Valid Sudoku|[Go]({{< relref "/ChapterFour/0001~0099/0036.Valid-Sudoku.md" >}})|Medium| O(n^2)| O(n^2)||50.4%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.2%|
|
||||
|0036|Valid Sudoku|[Go]({{< relref "/ChapterFour/0001~0099/0036.Valid-Sudoku.md" >}})|Medium| O(n^2)| O(n^2)||50.5%|
|
||||
|0037|Sudoku Solver|[Go]({{< relref "/ChapterFour/0001~0099/0037.Sudoku-Solver.md" >}})|Hard| O(n^2)| O(n^2)|❤️|46.4%|
|
||||
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.2%|
|
||||
|0076|Minimum Window Substring|[Go]({{< relref "/ChapterFour/0001~0099/0076.Minimum-Window-Substring.md" >}})|Hard| O(n)| O(n)|❤️|35.9%|
|
||||
@ -42,7 +42,7 @@ weight: 13
|
||||
|0463|Island Perimeter|[Go]({{< relref "/ChapterFour/0400~0499/0463.Island-Perimeter.md" >}})|Easy||||66.6%|
|
||||
|0500|Keyboard Row|[Go]({{< relref "/ChapterFour/0500~0599/0500.Keyboard-Row.md" >}})|Easy||||65.6%|
|
||||
|0508|Most Frequent Subtree Sum|[Go]({{< relref "/ChapterFour/0500~0599/0508.Most-Frequent-Subtree-Sum.md" >}})|Medium||||59.0%|
|
||||
|0575|Distribute Candies|[Go]({{< relref "/ChapterFour/0500~0599/0575.Distribute-Candies.md" >}})|Easy||||62.0%|
|
||||
|0575|Distribute Candies|[Go]({{< relref "/ChapterFour/0500~0599/0575.Distribute-Candies.md" >}})|Easy||||62.1%|
|
||||
|0594|Longest Harmonious Subsequence|[Go]({{< relref "/ChapterFour/0500~0599/0594.Longest-Harmonious-Subsequence.md" >}})|Easy||||51.2%|
|
||||
|0599|Minimum Index Sum of Two Lists|[Go]({{< relref "/ChapterFour/0500~0599/0599.Minimum-Index-Sum-of-Two-Lists.md" >}})|Easy||||51.6%|
|
||||
|0632|Smallest Range Covering Elements from K Lists|[Go]({{< relref "/ChapterFour/0600~0699/0632.Smallest-Range-Covering-Elements-from-K-Lists.md" >}})|Hard||||54.1%|
|
||||
@ -76,7 +76,7 @@ weight: 13
|
||||
|1207|Unique Number of Occurrences|[Go]({{< relref "/ChapterFour/1200~1299/1207.Unique-Number-of-Occurrences.md" >}})|Easy||||71.7%|
|
||||
|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%|
|
||||
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.2%|
|
||||
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.1%|
|
||||
|1679|Max Number of K-Sum Pairs|[Go]({{< relref "/ChapterFour/1600~1699/1679.Max-Number-of-K-Sum-Pairs.md" >}})|Medium||||54.2%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
@ -27,7 +27,7 @@ weight: 4
|
||||
|0019|Remove Nth Node From End of List|[Go]({{< relref "/ChapterFour/0001~0099/0019.Remove-Nth-Node-From-End-of-List.md" >}})|Medium| O(n)| O(1)||35.7%|
|
||||
|0021|Merge Two Sorted Lists|[Go]({{< relref "/ChapterFour/0001~0099/0021.Merge-Two-Sorted-Lists.md" >}})|Easy| O(log n)| O(1)||55.9%|
|
||||
|0023|Merge k Sorted Lists|[Go]({{< relref "/ChapterFour/0001~0099/0023.Merge-k-Sorted-Lists.md" >}})|Hard| O(log n)| O(1)|❤️|42.6%|
|
||||
|0024|Swap Nodes in Pairs|[Go]({{< relref "/ChapterFour/0001~0099/0024.Swap-Nodes-in-Pairs.md" >}})|Medium| O(n)| O(1)||52.9%|
|
||||
|0024|Swap Nodes in Pairs|[Go]({{< relref "/ChapterFour/0001~0099/0024.Swap-Nodes-in-Pairs.md" >}})|Medium| O(n)| O(1)||53.0%|
|
||||
|0025|Reverse Nodes in k-Group|[Go]({{< relref "/ChapterFour/0001~0099/0025.Reverse-Nodes-in-k-Group.md" >}})|Hard| O(log n)| O(1)|❤️|44.7%|
|
||||
|0061|Rotate List|[Go]({{< relref "/ChapterFour/0001~0099/0061.Rotate-List.md" >}})|Medium| O(n)| O(1)||31.7%|
|
||||
|0082|Remove Duplicates from Sorted List II|[Go]({{< relref "/ChapterFour/0001~0099/0082.Remove-Duplicates-from-Sorted-List-II.md" >}})|Medium| O(n)| O(1)||39.2%|
|
||||
|
@ -19,7 +19,7 @@ weight: 12
|
||||
|0067|Add Binary|[Go]({{< relref "/ChapterFour/0001~0099/0067.Add-Binary.md" >}})|Easy||||46.8%|
|
||||
|0069|Sqrt(x)|[Go]({{< relref "/ChapterFour/0001~0099/0069.Sqrtx.md" >}})|Easy| O(log n)| O(1)||35.0%|
|
||||
|0168|Excel Sheet Column Title|[Go]({{< relref "/ChapterFour/0100~0199/0168.Excel-Sheet-Column-Title.md" >}})|Easy||||31.7%|
|
||||
|0171|Excel Sheet Column Number|[Go]({{< relref "/ChapterFour/0100~0199/0171.Excel-Sheet-Column-Number.md" >}})|Easy||||56.8%|
|
||||
|0171|Excel Sheet Column Number|[Go]({{< relref "/ChapterFour/0100~0199/0171.Excel-Sheet-Column-Number.md" >}})|Easy||||56.9%|
|
||||
|0172|Factorial Trailing Zeroes|[Go]({{< relref "/ChapterFour/0100~0199/0172.Factorial-Trailing-Zeroes.md" >}})|Easy||||38.5%|
|
||||
|0202|Happy Number|[Go]({{< relref "/ChapterFour/0200~0299/0202.Happy-Number.md" >}})|Easy| O(log n)| O(1)||51.2%|
|
||||
|0204|Count Primes|[Go]({{< relref "/ChapterFour/0200~0299/0204.Count-Primes.md" >}})|Easy||||32.2%|
|
||||
@ -34,8 +34,8 @@ weight: 12
|
||||
|0357|Count Numbers with Unique Digits|[Go]({{< relref "/ChapterFour/0300~0399/0357.Count-Numbers-with-Unique-Digits.md" >}})|Medium| O(1)| O(1)||48.8%|
|
||||
|0367|Valid Perfect Square|[Go]({{< relref "/ChapterFour/0300~0399/0367.Valid-Perfect-Square.md" >}})|Easy||||42.0%|
|
||||
|0372|Super Pow|[Go]({{< relref "/ChapterFour/0300~0399/0372.Super-Pow.md" >}})|Medium||||36.7%|
|
||||
|0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium||||33.4%|
|
||||
|0441|Arranging Coins|[Go]({{< relref "/ChapterFour/0400~0499/0441.Arranging-Coins.md" >}})|Easy||||42.4%|
|
||||
|0397|Integer Replacement|[Go]({{< relref "/ChapterFour/0300~0399/0397.Integer-Replacement.md" >}})|Medium||||33.5%|
|
||||
|0441|Arranging Coins|[Go]({{< relref "/ChapterFour/0400~0499/0441.Arranging-Coins.md" >}})|Easy||||42.3%|
|
||||
|0447|Number of Boomerangs|[Go]({{< relref "/ChapterFour/0400~0499/0447.Number-of-Boomerangs.md" >}})|Medium||||52.4%|
|
||||
|0453|Minimum Moves to Equal Array Elements|[Go]({{< relref "/ChapterFour/0400~0499/0453.Minimum-Moves-to-Equal-Array-Elements.md" >}})|Easy||||50.8%|
|
||||
|0483|Smallest Good Base|[Go]({{< relref "/ChapterFour/0400~0499/0483.Smallest-Good-Base.md" >}})|Hard||||36.2%|
|
||||
@ -61,14 +61,14 @@ weight: 12
|
||||
|0949|Largest Time for Given Digits|[Go]({{< relref "/ChapterFour/0900~0999/0949.Largest-Time-for-Given-Digits.md" >}})|Medium||||36.2%|
|
||||
|0952|Largest Component Size by Common Factor|[Go]({{< relref "/ChapterFour/0900~0999/0952.Largest-Component-Size-by-Common-Factor.md" >}})|Hard||||36.1%|
|
||||
|0970|Powerful Integers|[Go]({{< relref "/ChapterFour/0900~0999/0970.Powerful-Integers.md" >}})|Medium||||40.0%|
|
||||
|0976|Largest Perimeter Triangle|[Go]({{< relref "/ChapterFour/0900~0999/0976.Largest-Perimeter-Triangle.md" >}})|Easy| O(n log n)| O(log n) ||58.6%|
|
||||
|0976|Largest Perimeter Triangle|[Go]({{< relref "/ChapterFour/0900~0999/0976.Largest-Perimeter-Triangle.md" >}})|Easy| O(n log n)| O(log n) ||58.5%|
|
||||
|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%|
|
||||
|1017|Convert to Base -2|[Go]({{< relref "/ChapterFour/1000~1099/1017.Convert-to-Base--2.md" >}})|Medium||||59.6%|
|
||||
|1025|Divisor Game|[Go]({{< relref "/ChapterFour/1000~1099/1025.Divisor-Game.md" >}})|Easy| O(1)| O(1)||66.2%|
|
||||
|1037|Valid Boomerang|[Go]({{< relref "/ChapterFour/1000~1099/1037.Valid-Boomerang.md" >}})|Easy||||37.8%|
|
||||
|1073|Adding Two Negabinary Numbers|[Go]({{< relref "/ChapterFour/1000~1099/1073.Adding-Two-Negabinary-Numbers.md" >}})|Medium||||34.8%|
|
||||
|1093|Statistics from a Large Sample|[Go]({{< relref "/ChapterFour/1000~1099/1093.Statistics-from-a-Large-Sample.md" >}})|Medium||||49.3%|
|
||||
|1154|Day of the Year|[Go]({{< relref "/ChapterFour/1100~1199/1154.Day-of-the-Year.md" >}})|Easy||||49.3%|
|
||||
|1154|Day of the Year|[Go]({{< relref "/ChapterFour/1100~1199/1154.Day-of-the-Year.md" >}})|Easy||||49.2%|
|
||||
|1175|Prime Arrangements|[Go]({{< relref "/ChapterFour/1100~1199/1175.Prime-Arrangements.md" >}})|Easy||||52.0%|
|
||||
|1201|Ugly Number III|[Go]({{< relref "/ChapterFour/1200~1299/1201.Ugly-Number-III.md" >}})|Medium||||26.4%|
|
||||
|1217|Minimum Cost to Move Chips to The Same Position|[Go]({{< relref "/ChapterFour/1200~1299/1217.Minimum-Cost-to-Move-Chips-to-The-Same-Position.md" >}})|Easy||||71.2%|
|
||||
|
@ -35,7 +35,7 @@ weight: 17
|
||||
|0424|Longest Repeating Character Replacement|[Go]({{< relref "/ChapterFour/0400~0499/0424.Longest-Repeating-Character-Replacement.md" >}})|Medium| O(n)| O(1) ||48.2%|
|
||||
|0480|Sliding Window Median|[Go]({{< relref "/ChapterFour/0400~0499/0480.Sliding-Window-Median.md" >}})|Hard| O(n * log k)| O(k)|❤️|38.6%|
|
||||
|0567|Permutation in String|[Go]({{< relref "/ChapterFour/0500~0599/0567.Permutation-in-String.md" >}})|Medium| O(n)| O(1)|❤️|44.6%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium| O(n)| O(1)|❤️|46.6%|
|
||||
|0978|Longest Turbulent Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0978.Longest-Turbulent-Subarray.md" >}})|Medium| O(n)| O(1)|❤️|46.7%|
|
||||
|0992|Subarrays with K Different Integers|[Go]({{< relref "/ChapterFour/0900~0999/0992.Subarrays-with-K-Different-Integers.md" >}})|Hard| O(n)| O(n)|❤️|50.6%|
|
||||
|0995|Minimum Number of K Consecutive Bit Flips|[Go]({{< relref "/ChapterFour/0900~0999/0995.Minimum-Number-of-K-Consecutive-Bit-Flips.md" >}})|Hard| O(n)| O(1)|❤️|49.8%|
|
||||
|1004|Max Consecutive Ones III|[Go]({{< relref "/ChapterFour/1000~1099/1004.Max-Consecutive-Ones-III.md" >}})|Medium| O(n)| O(1) ||60.7%|
|
||||
|
@ -41,17 +41,18 @@ weight: 14
|
||||
|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 log n)| O(log n) |❤️|68.6%|
|
||||
|0973|K Closest Points to Origin|[Go]({{< relref "/ChapterFour/0900~0999/0973.K-Closest-Points-to-Origin.md" >}})|Medium| O(n log n)| O(log n) ||64.6%|
|
||||
|0976|Largest Perimeter Triangle|[Go]({{< relref "/ChapterFour/0900~0999/0976.Largest-Perimeter-Triangle.md" >}})|Easy| O(n log n)| O(log n) ||58.6%|
|
||||
|0976|Largest Perimeter Triangle|[Go]({{< relref "/ChapterFour/0900~0999/0976.Largest-Perimeter-Triangle.md" >}})|Easy| O(n log n)| O(log n) ||58.5%|
|
||||
|1030|Matrix Cells in Distance Order|[Go]({{< relref "/ChapterFour/1000~1099/1030.Matrix-Cells-in-Distance-Order.md" >}})|Easy| O(n^2)| O(1) ||66.9%|
|
||||
|1054|Distant Barcodes|[Go]({{< relref "/ChapterFour/1000~1099/1054.Distant-Barcodes.md" >}})|Medium| O(n log n)| O(log n) |❤️|44.2%|
|
||||
|1122|Relative Sort Array|[Go]({{< relref "/ChapterFour/1100~1199/1122.Relative-Sort-Array.md" >}})|Easy||||68.1%|
|
||||
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.3%|
|
||||
|1235|Maximum Profit in Job Scheduling|[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})|Hard||||47.4%|
|
||||
|1305|All Elements in Two Binary Search Trees|[Go]({{< relref "/ChapterFour/1300~1399/1305.All-Elements-in-Two-Binary-Search-Trees.md" >}})|Medium||||77.8%|
|
||||
|1329|Sort the Matrix Diagonally|[Go]({{< relref "/ChapterFour/1300~1399/1329.Sort-the-Matrix-Diagonally.md" >}})|Medium||||81.8%|
|
||||
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.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%|
|
||||
|1647|Minimum Deletions to Make Character Frequencies Unique|[Go]({{< relref "/ChapterFour/1600~1699/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique.md" >}})|Medium||||54.5%|
|
||||
|1648|Sell Diminishing-Valued Colored Balls|[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})|Medium||||30.8%|
|
||||
|1691|Maximum Height by Stacking Cuboids|[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})|Hard||||49.9%|
|
||||
|1691|Maximum Height by Stacking Cuboids|[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})|Hard||||50.0%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ weight: 5
|
||||
|0155|Min Stack|[Go]({{< relref "/ChapterFour/0100~0199/0155.Min-Stack.md" >}})|Easy| O(n)| O(n)||46.3%|
|
||||
|0173|Binary Search Tree Iterator|[Go]({{< relref "/ChapterFour/0100~0199/0173.Binary-Search-Tree-Iterator.md" >}})|Medium| O(n)| O(1)||60.0%|
|
||||
|0224|Basic Calculator|[Go]({{< relref "/ChapterFour/0200~0299/0224.Basic-Calculator.md" >}})|Hard| O(n)| O(n)||38.1%|
|
||||
|0225|Implement Stack using Queues|[Go]({{< relref "/ChapterFour/0200~0299/0225.Implement-Stack-using-Queues.md" >}})|Easy| O(n)| O(n)||47.2%|
|
||||
|0225|Implement Stack using Queues|[Go]({{< relref "/ChapterFour/0200~0299/0225.Implement-Stack-using-Queues.md" >}})|Easy| O(n)| O(n)||47.3%|
|
||||
|0232|Implement Queue using Stacks|[Go]({{< relref "/ChapterFour/0200~0299/0232.Implement-Queue-using-Stacks.md" >}})|Easy| O(n)| O(n)||52.0%|
|
||||
|0331|Verify Preorder Serialization of a Binary Tree|[Go]({{< relref "/ChapterFour/0300~0399/0331.Verify-Preorder-Serialization-of-a-Binary-Tree.md" >}})|Medium| O(n)| O(1)||41.0%|
|
||||
|0385|Mini Parser|[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})|Medium||||34.5%|
|
||||
@ -41,7 +41,7 @@ weight: 5
|
||||
|0636|Exclusive Time of Functions|[Go]({{< relref "/ChapterFour/0600~0699/0636.Exclusive-Time-of-Functions.md" >}})|Medium| O(n)| O(n)||54.3%|
|
||||
|0682|Baseball Game|[Go]({{< relref "/ChapterFour/0600~0699/0682.Baseball-Game.md" >}})|Easy| O(n)| O(n)||66.7%|
|
||||
|0726|Number of Atoms|[Go]({{< relref "/ChapterFour/0700~0799/0726.Number-of-Atoms.md" >}})|Hard| O(n)| O(n) |❤️|51.1%|
|
||||
|0735|Asteroid Collision|[Go]({{< relref "/ChapterFour/0700~0799/0735.Asteroid-Collision.md" >}})|Medium| O(n)| O(n) ||43.2%|
|
||||
|0735|Asteroid Collision|[Go]({{< relref "/ChapterFour/0700~0799/0735.Asteroid-Collision.md" >}})|Medium| O(n)| O(n) ||43.3%|
|
||||
|0739|Daily Temperatures|[Go]({{< relref "/ChapterFour/0700~0799/0739.Daily-Temperatures.md" >}})|Medium| O(n)| O(n) ||64.5%|
|
||||
|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||46.9%|
|
||||
|0856|Score of Parentheses|[Go]({{< relref "/ChapterFour/0800~0899/0856.Score-of-Parentheses.md" >}})|Medium| O(n)| O(n)||62.4%|
|
||||
|
@ -13,9 +13,9 @@ weight: 2
|
||||
|0013|Roman to Integer|[Go]({{< relref "/ChapterFour/0001~0099/0013.Roman-to-Integer.md" >}})|Easy||||56.5%|
|
||||
|0017|Letter Combinations of a Phone Number|[Go]({{< relref "/ChapterFour/0001~0099/0017.Letter-Combinations-of-a-Phone-Number.md" >}})|Medium| O(log n)| O(1)||49.0%|
|
||||
|0020|Valid Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0020.Valid-Parentheses.md" >}})|Easy| O(log n)| O(1)||39.8%|
|
||||
|0022|Generate Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0022.Generate-Parentheses.md" >}})|Medium| O(log n)| O(1)||65.1%|
|
||||
|0022|Generate Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0022.Generate-Parentheses.md" >}})|Medium| O(log n)| O(1)||65.2%|
|
||||
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.2%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.2%|
|
||||
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||59.2%|
|
||||
|0067|Add Binary|[Go]({{< relref "/ChapterFour/0001~0099/0067.Add-Binary.md" >}})|Easy||||46.8%|
|
||||
|0071|Simplify Path|[Go]({{< relref "/ChapterFour/0001~0099/0071.Simplify-Path.md" >}})|Medium| O(n)| O(n)||34.6%|
|
||||
@ -46,12 +46,15 @@ weight: 2
|
||||
|1234|Replace the Substring for Balanced String|[Go]({{< relref "/ChapterFour/1200~1299/1234.Replace-the-Substring-for-Balanced-String.md" >}})|Medium||||34.3%|
|
||||
|1455|Check If a Word Occurs As a Prefix of Any Word in a Sentence|[Go]({{< relref "/ChapterFour/1400~1499/1455.Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence.md" >}})|Easy||||64.4%|
|
||||
|1573|Number of Ways to Split a String|[Go]({{< relref "/ChapterFour/1500~1599/1573.Number-of-Ways-to-Split-a-String.md" >}})|Medium||||31.0%|
|
||||
|1653|Minimum Deletions to Make String Balanced|[Go]({{< relref "/ChapterFour/1600~1699/1653.Minimum-Deletions-to-Make-String-Balanced.md" >}})|Medium||||50.6%|
|
||||
|1662|Check If Two String Arrays are Equivalent|[Go]({{< relref "/ChapterFour/1600~1699/1662.Check-If-Two-String-Arrays-are-Equivalent.md" >}})|Easy||||83.3%|
|
||||
|1614|Maximum Nesting Depth of the Parentheses|[Go]({{< relref "/ChapterFour/1600~1699/1614.Maximum-Nesting-Depth-of-the-Parentheses.md" >}})|Easy||||83.1%|
|
||||
|1624|Largest Substring Between Two Equal Characters|[Go]({{< relref "/ChapterFour/1600~1699/1624.Largest-Substring-Between-Two-Equal-Characters.md" >}})|Easy||||58.9%|
|
||||
|1653|Minimum Deletions to Make String Balanced|[Go]({{< relref "/ChapterFour/1600~1699/1653.Minimum-Deletions-to-Make-String-Balanced.md" >}})|Medium||||50.5%|
|
||||
|1662|Check If Two String Arrays are Equivalent|[Go]({{< relref "/ChapterFour/1600~1699/1662.Check-If-Two-String-Arrays-are-Equivalent.md" >}})|Easy||||83.2%|
|
||||
|1668|Maximum Repeating Substring|[Go]({{< relref "/ChapterFour/1600~1699/1668.Maximum-Repeating-Substring.md" >}})|Easy||||38.5%|
|
||||
|1678|Goal Parser Interpretation|[Go]({{< relref "/ChapterFour/1600~1699/1678.Goal-Parser-Interpretation.md" >}})|Easy||||85.7%|
|
||||
|1684|Count the Number of Consistent Strings|[Go]({{< relref "/ChapterFour/1600~1699/1684.Count-the-Number-of-Consistent-Strings.md" >}})|Easy||||83.2%|
|
||||
|1694|Reformat Phone Number|[Go]({{< relref "/ChapterFour/1600~1699/1694.Reformat-Phone-Number.md" >}})|Easy||||66.3%|
|
||||
|1694|Reformat Phone Number|[Go]({{< relref "/ChapterFour/1600~1699/1694.Reformat-Phone-Number.md" >}})|Easy||||66.2%|
|
||||
|1704|Determine if String Halves Are Alike|[Go]({{< relref "/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md" >}})|Easy||||77.6%|
|
||||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ weight: 3
|
||||
|0026|Remove Duplicates from Sorted Array|[Go]({{< relref "/ChapterFour/0001~0099/0026.Remove-Duplicates-from-Sorted-Array.md" >}})|Easy| O(n)| O(1)||46.5%|
|
||||
|0027|Remove Element|[Go]({{< relref "/ChapterFour/0001~0099/0027.Remove-Element.md" >}})|Easy| O(n)| O(1)||49.2%|
|
||||
|0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.2%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.1%|
|
||||
|0030|Substring with Concatenation of All Words|[Go]({{< relref "/ChapterFour/0001~0099/0030.Substring-with-Concatenation-of-All-Words.md" >}})|Hard| O(n)| O(n)|❤️|26.2%|
|
||||
|0042|Trapping Rain Water|[Go]({{< relref "/ChapterFour/0001~0099/0042.Trapping-Rain-Water.md" >}})|Hard| O(n)| O(1)|❤️|51.0%|
|
||||
|0061|Rotate List|[Go]({{< relref "/ChapterFour/0001~0099/0061.Rotate-List.md" >}})|Medium| O(n)| O(1)||31.7%|
|
||||
|0075|Sort Colors|[Go]({{< relref "/ChapterFour/0001~0099/0075.Sort-Colors.md" >}})|Medium| O(n)| O(1)|❤️|49.3%|
|
||||
@ -69,7 +69,7 @@ weight: 3
|
||||
|0632|Smallest Range Covering Elements from K Lists|[Go]({{< relref "/ChapterFour/0600~0699/0632.Smallest-Range-Covering-Elements-from-K-Lists.md" >}})|Hard||||54.1%|
|
||||
|0713|Subarray Product Less Than K|[Go]({{< relref "/ChapterFour/0700~0799/0713.Subarray-Product-Less-Than-K.md" >}})|Medium| O(n)| O(1)||40.5%|
|
||||
|0763|Partition Labels|[Go]({{< relref "/ChapterFour/0700~0799/0763.Partition-Labels.md" >}})|Medium| O(n)| O(1)|❤️|78.0%|
|
||||
|0826|Most Profit Assigning Work|[Go]({{< relref "/ChapterFour/0800~0899/0826.Most-Profit-Assigning-Work.md" >}})|Medium| O(n log n)| O(n)||39.0%|
|
||||
|0826|Most Profit Assigning Work|[Go]({{< relref "/ChapterFour/0800~0899/0826.Most-Profit-Assigning-Work.md" >}})|Medium| O(n log n)| O(n)||39.1%|
|
||||
|0828|Count Unique Characters of All Substrings of a Given String|[Go]({{< relref "/ChapterFour/0800~0899/0828.Count-Unique-Characters-of-All-Substrings-of-a-Given-String.md" >}})|Hard| O(n)| O(1)|❤️|46.8%|
|
||||
|0838|Push Dominoes|[Go]({{< relref "/ChapterFour/0800~0899/0838.Push-Dominoes.md" >}})|Medium| O(n)| O(n)||49.8%|
|
||||
|0844|Backspace String Compare|[Go]({{< relref "/ChapterFour/0800~0899/0844.Backspace-String-Compare.md" >}})|Easy| O(n)| O(n) ||46.9%|
|
||||
|
@ -21,17 +21,17 @@ weight: 16
|
||||
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
|
||||
|0128|Longest Consecutive Sequence|[Go]({{< relref "/ChapterFour/0100~0199/0128.Longest-Consecutive-Sequence.md" >}})|Hard| O(n)| O(n)|❤️|46.2%|
|
||||
|0130|Surrounded Regions|[Go]({{< relref "/ChapterFour/0100~0199/0130.Surrounded-Regions.md" >}})|Medium| O(m\*n)| O(m\*n)||29.3%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(m\*n)| O(m\*n)||48.9%|
|
||||
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(m\*n)| O(m\*n)||49.0%|
|
||||
|0399|Evaluate Division|[Go]({{< relref "/ChapterFour/0300~0399/0399.Evaluate-Division.md" >}})|Medium| O(n)| O(n)||54.2%|
|
||||
|0547|Number of Provinces|[Go]({{< relref "/ChapterFour/0500~0599/0547.Number-of-Provinces.md" >}})|Medium| O(n^2)| O(n)||60.4%|
|
||||
|0684|Redundant Connection|[Go]({{< relref "/ChapterFour/0600~0699/0684.Redundant-Connection.md" >}})|Medium| O(n)| O(n)||58.9%|
|
||||
|0685|Redundant Connection II|[Go]({{< relref "/ChapterFour/0600~0699/0685.Redundant-Connection-II.md" >}})|Hard| O(n)| O(n)||33.0%|
|
||||
|0721|Accounts Merge|[Go]({{< relref "/ChapterFour/0700~0799/0721.Accounts-Merge.md" >}})|Medium| O(n)| O(n)|❤️|51.6%|
|
||||
|0765|Couples Holding Hands|[Go]({{< relref "/ChapterFour/0700~0799/0765.Couples-Holding-Hands.md" >}})|Hard| O(n)| O(n)|❤️|55.4%|
|
||||
|0765|Couples Holding Hands|[Go]({{< relref "/ChapterFour/0700~0799/0765.Couples-Holding-Hands.md" >}})|Hard| O(n)| O(n)|❤️|55.5%|
|
||||
|0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard| O(n^2)| O(n)|❤️|54.8%|
|
||||
|0803|Bricks Falling When Hit|[Go]({{< relref "/ChapterFour/0800~0899/0803.Bricks-Falling-When-Hit.md" >}})|Hard| O(n^2)| O(n)|❤️|31.4%|
|
||||
|0839|Similar String Groups|[Go]({{< relref "/ChapterFour/0800~0899/0839.Similar-String-Groups.md" >}})|Hard| O(n^2)| O(n)||40.5%|
|
||||
|0924|Minimize Malware Spread|[Go]({{< relref "/ChapterFour/0900~0999/0924.Minimize-Malware-Spread.md" >}})|Hard| O(m\*n)| O(n)||41.8%|
|
||||
|0924|Minimize Malware Spread|[Go]({{< relref "/ChapterFour/0900~0999/0924.Minimize-Malware-Spread.md" >}})|Hard| O(m\*n)| O(n)||41.9%|
|
||||
|0928|Minimize Malware Spread II|[Go]({{< relref "/ChapterFour/0900~0999/0928.Minimize-Malware-Spread-II.md" >}})|Hard| O(m\*n)| O(n)|❤️|41.2%|
|
||||
|0947|Most Stones Removed with Same Row or Column|[Go]({{< relref "/ChapterFour/0900~0999/0947.Most-Stones-Removed-with-Same-Row-or-Column.md" >}})|Medium| O(n)| O(n)||55.4%|
|
||||
|0952|Largest Component Size by Common Factor|[Go]({{< relref "/ChapterFour/0900~0999/0952.Largest-Component-Size-by-Common-Factor.md" >}})|Hard| O(n)| O(n)|❤️|36.1%|
|
||||
|
Reference in New Issue
Block a user