Add solution 417、916

This commit is contained in:
YDZ
2021-03-27 02:31:31 +08:00
parent 1781d4e7a5
commit 427b25d4b7
22 changed files with 689 additions and 82 deletions

126
README.md
View File

@ -126,16 +126,16 @@
| | Easy | Medium | Hard | Total |
|:--------:|:--------:|:--------:|:--------:|:--------:|
|Optimizing|36|39|16|91|
|Accepted|**272**|**354**|**104**|**730**|
|Optimizing|36|38|16|90|
|Accepted|**272**|**355**|**104**|**731**|
|Total|471|952|381|1804|
|Perfection Rate|86.8%|89.0%|84.6%|87.5%|
|Completion Rate|57.7%|37.2%|27.3%|40.5%|
|Perfection Rate|86.8%|89.3%|84.6%|87.7%|
|Completion Rate|57.7%|37.3%|27.3%|40.5%|
|------------|----------------------------|----------------------------|----------------------------|----------------------------|
## 二. 目录
以下已经收录了 639 道题的题解,还有 12 道题在尝试优化到 beats 100%
以下已经收录了 641 道题的题解,还有 12 道题在尝试优化到 beats 100%
| No. | Title | Solution | Acceptance | Difficulty | Frequency |
|:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|
@ -358,7 +358,7 @@
|0217|Contains Duplicate|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0217.Contains-Duplicate)|56.8%|Easy||
|0218|The Skyline Problem|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0218.The-Skyline-Problem)|36.5%|Hard||
|0219|Contains Duplicate II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0219.Contains-Duplicate-II)|38.8%|Easy||
|0220|Contains Duplicate III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0220.Contains-Duplicate-III)|21.4%|Medium||
|0220|Contains Duplicate III|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0220.Contains-Duplicate-III)|21.3%|Medium||
|0221|Maximal Square||39.5%|Medium||
|0222|Count Complete Tree Nodes|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0222.Count-Complete-Tree-Nodes)|49.6%|Medium||
|0223|Rectangle Area|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0223.Rectangle-Area)|38.3%|Medium||
@ -382,7 +382,7 @@
|0241|Different Ways to Add Parentheses||57.5%|Medium||
|0242|Valid Anagram|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0242.Valid-Anagram)|58.8%|Easy||
|0243|Shortest Word Distance||62.0%|Easy||
|0244|Shortest Word Distance II||54.3%|Medium||
|0244|Shortest Word Distance II||54.4%|Medium||
|0245|Shortest Word Distance III||56.1%|Medium||
|0246|Strobogrammatic Number||46.4%|Easy||
|0247|Strobogrammatic Number II||48.7%|Medium||
@ -402,7 +402,7 @@
|0261|Graph Valid Tree||43.3%|Medium||
|0262|Trips and Users||35.3%|Hard||
|0263|Ugly Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0263.Ugly-Number)|41.7%|Easy||
|0264|Ugly Number II||42.9%|Medium||
|0264|Ugly Number II||43.0%|Medium||
|0265|Paint House II||45.8%|Hard||
|0266|Palindrome Permutation||62.6%|Easy||
|0267|Palindrome Permutation II||37.5%|Medium||
@ -446,7 +446,7 @@
|0305|Number of Islands II||39.6%|Hard||
|0306|Additive Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0306.Additive-Number)|29.7%|Medium||
|0307|Range Sum Query - Mutable|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0307.Range-Sum-Query---Mutable)|36.8%|Medium||
|0308|Range Sum Query 2D - Mutable||37.9%|Hard||
|0308|Range Sum Query 2D - Mutable||38.0%|Hard||
|0309|Best Time to Buy and Sell Stock with Cooldown|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0309.Best-Time-to-Buy-and-Sell-Stock-with-Cooldown)|48.3%|Medium||
|0310|Minimum Height Trees||34.8%|Medium||
|0311|Sparse Matrix Multiplication||64.1%|Medium||
@ -523,7 +523,7 @@
|0382|Linked List Random Node||54.2%|Medium||
|0383|Ransom Note||53.4%|Easy||
|0384|Shuffle an Array||54.1%|Medium||
|0385|Mini Parser|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0385.Mini-Parser)|34.5%|Medium||
|0385|Mini Parser|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0385.Mini-Parser)|34.6%|Medium||
|0386|Lexicographical Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0386.Lexicographical-Numbers)|54.4%|Medium||
|0387|First Unique Character in a String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0387.First-Unique-Character-in-a-String)|53.8%|Easy||
|0388|Longest Absolute File Path||43.1%|Medium||
@ -547,7 +547,7 @@
|0406|Queue Reconstruction by Height||68.5%|Medium||
|0407|Trapping Rain Water II||44.4%|Hard||
|0408|Valid Word Abbreviation||31.4%|Easy||
|0409|Longest Palindrome|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0409.Longest-Palindrome)|52.2%|Easy||
|0409|Longest Palindrome|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0409.Longest-Palindrome)|52.3%|Easy||
|0410|Split Array Largest Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0410.Split-Array-Largest-Sum)|46.6%|Hard||
|0411|Minimum Unique Word Abbreviation||37.3%|Hard||
|0412|Fizz Buzz|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0412.Fizz-Buzz)|63.6%|Easy||
@ -555,9 +555,9 @@
|0414|Third Maximum Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0414.Third-Maximum-Number)|30.7%|Easy||
|0415|Add Strings||48.3%|Easy||
|0416|Partition Equal Subset Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0416.Partition-Equal-Subset-Sum)|44.9%|Medium||
|0417|Pacific Atlantic Water Flow||43.8%|Medium||
|0417|Pacific Atlantic Water Flow|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0417.Pacific-Atlantic-Water-Flow)|43.8%|Medium||
|0418|Sentence Screen Fitting||33.4%|Medium||
|0419|Battleships in a Board||71.2%|Medium||
|0419|Battleships in a Board||71.1%|Medium||
|0420|Strong Password Checker||14.0%|Hard||
|0421|Maximum XOR of Two Numbers in an Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0421.Maximum-XOR-of-Two-Numbers-in-an-Array)|54.3%|Medium||
|0422|Valid Word Square||38.2%|Easy||
@ -626,7 +626,7 @@
|0485|Max Consecutive Ones|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0485.Max-Consecutive-Ones)|52.7%|Easy||
|0486|Predict the Winner||49.0%|Medium||
|0487|Max Consecutive Ones II||48.0%|Medium||
|0488|Zuma Game||38.2%|Hard||
|0488|Zuma Game||38.1%|Hard||
|0489|Robot Room Cleaner||72.8%|Hard||
|0490|The Maze||52.8%|Medium||
|0491|Increasing Subsequences|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0491.Increasing-Subsequences)|47.6%|Medium||
@ -659,7 +659,7 @@
|0518|Coin Change 2||52.0%|Medium||
|0519|Random Flip Matrix||37.8%|Medium||
|0520|Detect Capital||54.0%|Easy||
|0521|Longest Uncommon Subsequence I||58.9%|Easy||
|0521|Longest Uncommon Subsequence I||59.0%|Easy||
|0522|Longest Uncommon Subsequence II||34.3%|Medium||
|0523|Continuous Subarray Sum||24.7%|Medium||
|0524|Longest Word in Dictionary through Deleting|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0524.Longest-Word-in-Dictionary-through-Deleting)|50.1%|Medium||
@ -746,13 +746,13 @@
|0605|Can Place Flowers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0605.Can-Place-Flowers)|31.7%|Easy||
|0606|Construct String from Binary Tree||55.5%|Easy||
|0607|Sales Person||65.3%|Easy||
|0608|Tree Node||69.8%|Medium||
|0608|Tree Node||69.9%|Medium||
|0609|Find Duplicate File in System||61.1%|Medium||
|0610|Triangle Judgement||68.8%|Easy||
|0611|Valid Triangle Number||49.4%|Medium||
|0612|Shortest Distance in a Plane||61.6%|Medium||
|0613|Shortest Distance in a Line||79.8%|Easy||
|0614|Second Degree Follower||32.7%|Medium||
|0614|Second Degree Follower||32.8%|Medium||
|0615|Average Salary: Departments VS Company||52.9%|Hard||
|0616|Add Bold Tag in String||44.8%|Medium||
|0617|Merge Two Binary Trees||75.5%|Easy||
@ -763,7 +763,7 @@
|0622|Design Circular Queue||46.0%|Medium||
|0623|Add One Row to Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0623.Add-One-Row-to-Tree)|53.0%|Medium||
|0624|Maximum Distance in Arrays||39.6%|Medium||
|0625|Minimum Factorization||32.9%|Medium||
|0625|Minimum Factorization||33.0%|Medium||
|0626|Exchange Seats||66.0%|Medium||
|0627|Swap Salary||77.9%|Easy||
|0628|Maximum Product of Three Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0628.Maximum-Product-of-Three-Numbers)|46.8%|Easy||
@ -808,7 +808,7 @@
|0667|Beautiful Arrangement II||55.2%|Medium||
|0668|Kth Smallest Number in Multiplication Table|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0668.Kth-Smallest-Number-in-Multiplication-Table)|47.8%|Hard||
|0669|Trim a Binary Search Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0669.Trim-a-Binary-Search-Tree)|64.4%|Medium||
|0670|Maximum Swap||45.2%|Medium||
|0670|Maximum Swap||45.3%|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.6%|Medium||
@ -843,7 +843,7 @@
|0702|Search in a Sorted Array of Unknown Size||68.9%|Medium||
|0703|Kth Largest Element in a Stream|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0703.Kth-Largest-Element-in-a-Stream)|50.8%|Easy||
|0704|Binary Search|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0704.Binary-Search)|54.2%|Easy||
|0705|Design HashSet|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0705.Design-HashSet)|64.6%|Easy||
|0705|Design HashSet|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0705.Design-HashSet)|64.5%|Easy||
|0706|Design HashMap|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0706.Design-HashMap)|64.2%|Easy||
|0707|Design Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0707.Design-Linked-List)|26.0%|Medium||
|0708|Insert into a Sorted Circular Linked List||32.6%|Medium||
@ -861,7 +861,7 @@
|0720|Longest Word in Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0720.Longest-Word-in-Dictionary)|49.3%|Easy||
|0721|Accounts Merge|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0721.Accounts-Merge)|52.1%|Medium||
|0722|Remove Comments||36.3%|Medium||
|0723|Candy Crush||72.9%|Medium||
|0723|Candy Crush||73.0%|Medium||
|0724|Find Pivot Index|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0724.Find-Pivot-Index)|45.9%|Easy||
|0725|Split Linked List in Parts|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0725.Split-Linked-List-in-Parts)|53.1%|Medium||
|0726|Number of Atoms|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0726.Number-of-Atoms)|51.0%|Hard||
@ -895,7 +895,7 @@
|0754|Reach a Number||40.5%|Medium||
|0755|Pour Water||44.2%|Medium||
|0756|Pyramid Transition Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0756.Pyramid-Transition-Matrix)|55.6%|Medium||
|0757|Set Intersection Size At Least Two||42.6%|Hard||
|0757|Set Intersection Size At Least Two||42.5%|Hard||
|0758|Bold Words in String||47.5%|Easy||
|0759|Employee Free Time||68.3%|Hard||
|0760|Find Anagram Mappings||81.9%|Easy||
@ -967,7 +967,7 @@
|0826|Most Profit Assigning Work|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0826.Most-Profit-Assigning-Work)|39.2%|Medium||
|0827|Making A Large Island||47.4%|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||
|0829|Consecutive Numbers Sum||39.2%|Hard||
|0830|Positions of Large Groups|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0830.Positions-of-Large-Groups)|50.5%|Easy||
|0831|Masking Personal Information||44.8%|Medium||
|0832|Flipping an Image|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0832.Flipping-an-Image)|78.3%|Easy||
@ -985,7 +985,7 @@
|0844|Backspace String Compare|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0844.Backspace-String-Compare)|47.1%|Easy||
|0845|Longest Mountain in Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0845.Longest-Mountain-in-Array)|38.6%|Medium||
|0846|Hand of Straights||55.5%|Medium||
|0847|Shortest Path Visiting All Nodes||53.9%|Hard||
|0847|Shortest Path Visiting All Nodes||54.0%|Hard||
|0848|Shifting Letters||45.2%|Medium||
|0849|Maximize Distance to Closest Person||44.5%|Medium||
|0850|Rectangle Area II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0850.Rectangle-Area-II)|48.4%|Hard||
@ -996,7 +996,7 @@
|0855|Exam Room||43.4%|Medium||
|0856|Score of Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0856.Score-of-Parentheses)|64.9%|Medium||
|0857|Minimum Cost to Hire K Workers||50.5%|Hard||
|0858|Mirror Reflection||59.7%|Medium||
|0858|Mirror Reflection||59.6%|Medium||
|0859|Buddy Strings||29.2%|Easy||
|0860|Lemonade Change||51.8%|Easy||
|0861|Score After Flipping Matrix||73.7%|Medium||
@ -1054,7 +1054,7 @@
|0913|Cat and Mouse||34.8%|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.1%|Easy||
|0915|Partition Array into Disjoint Intervals||46.2%|Medium||
|0916|Word Subsets||50.8%|Medium||
|0916|Word Subsets|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0916.Word-Subsets)|51.2%|Medium||
|0917|Reverse Only Letters||59.2%|Easy||
|0918|Maximum Sum Circular Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0918.Maximum-Sum-Circular-Subarray)|34.3%|Medium||
|0919|Complete Binary Tree Inserter||59.0%|Medium||
@ -1091,7 +1091,7 @@
|0950|Reveal Cards In Increasing Order||75.4%|Medium||
|0951|Flip Equivalent Binary Trees||65.7%|Medium||
|0952|Largest Component Size by Common Factor|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0952.Largest-Component-Size-by-Common-Factor)|36.2%|Hard||
|0953|Verifying an Alien Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0953.Verifying-an-Alien-Dictionary)|51.8%|Easy||
|0953|Verifying an Alien Dictionary|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0953.Verifying-an-Alien-Dictionary)|51.9%|Easy||
|0954|Array of Doubled Pairs||35.1%|Medium||
|0955|Delete Columns to Make Sorted II||33.9%|Medium||
|0956|Tallest Billboard||39.9%|Hard||
@ -1107,7 +1107,7 @@
|0966|Vowel Spellchecker|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0966.Vowel-Spellchecker)|51.9%|Medium||
|0967|Numbers With Same Consecutive Differences||45.0%|Medium||
|0968|Binary Tree Cameras|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0968.Binary-Tree-Cameras)|38.8%|Hard||
|0969|Pancake Sorting|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0969.Pancake-Sorting)|68.8%|Medium||
|0969|Pancake Sorting|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0969.Pancake-Sorting)|68.7%|Medium||
|0970|Powerful Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0970.Powerful-Integers)|40.0%|Medium||
|0971|Flip Binary Tree To Match Preorder Traversal||46.1%|Medium||
|0972|Equal Rational Numbers||42.1%|Hard||
@ -1254,7 +1254,7 @@
|1113|Reported Posts||66.0%|Easy||
|1114|Print in Order||67.2%|Easy||
|1115|Print FooBar Alternately||59.0%|Medium||
|1116|Print Zero Even Odd||57.7%|Medium||
|1116|Print Zero Even Odd||57.8%|Medium||
|1117|Building H2O||53.1%|Medium||
|1118|Number of Days in a Month||57.3%|Easy||
|1119|Remove Vowels from a String||90.5%|Easy||
@ -1271,7 +1271,7 @@
|1130|Minimum Cost Tree From Leaf Values||67.3%|Medium||
|1131|Maximum of Absolute Value Expression||51.6%|Medium||
|1132|Reported Posts II||34.7%|Medium||
|1133|Largest Unique Number||67.3%|Easy||
|1133|Largest Unique Number||67.2%|Easy||
|1134|Armstrong Number||78.1%|Easy||
|1135|Connecting Cities With Minimum Cost||59.5%|Medium||
|1136|Parallel Courses||60.6%|Medium||
@ -1352,7 +1352,7 @@
|1211|Queries Quality and Percentage||70.2%|Easy||
|1212|Team Scores in Football Tournament||56.9%|Medium||
|1213|Intersection of Three Sorted Arrays||79.4%|Easy||
|1214|Two Sum BSTs||67.6%|Medium||
|1214|Two Sum BSTs||67.5%|Medium||
|1215|Stepping Numbers||43.6%|Medium||
|1216|Valid Palindrome III||49.9%|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.1%|Easy||
@ -1497,7 +1497,7 @@
|1356|Sort Integers by The Number of 1 Bits||69.8%|Easy||
|1357|Apply Discount Every n Orders||66.9%|Medium||
|1358|Number of Substrings Containing All Three Characters||60.5%|Medium||
|1359|Count All Valid Pickup and Delivery Options||56.3%|Hard||
|1359|Count All Valid Pickup and Delivery Options||56.2%|Hard||
|1360|Number of Days Between Two Dates||46.6%|Easy||
|1361|Validate Binary Tree Nodes||43.5%|Medium||
|1362|Closest Divisors||57.8%|Medium||
@ -1509,10 +1509,10 @@
|1368|Minimum Cost to Make at Least One Valid Path in a Grid||57.4%|Hard||
|1369|Get the Second Most Recent Activity||69.0%|Hard||
|1370|Increasing Decreasing String||77.3%|Easy||
|1371|Find the Longest Substring Containing Vowels in Even Counts||60.9%|Medium||
|1371|Find the Longest Substring Containing Vowels in Even Counts||60.8%|Medium||
|1372|Longest ZigZag Path in a Binary Tree||55.0%|Medium||
|1373|Maximum Sum BST in Binary Tree||37.3%|Hard||
|1374|Generate a String With Characters That Have Odd Counts||76.9%|Easy||
|1374|Generate a String With Characters That Have Odd Counts||76.8%|Easy||
|1375|Bulb Switcher III||64.2%|Medium||
|1376|Time Needed to Inform All Employees||56.6%|Medium||
|1377|Frog Position After T Seconds||35.3%|Hard||
@ -1589,7 +1589,7 @@
|1448|Count Good Nodes in Binary Tree||71.1%|Medium||
|1449|Form Largest Integer With Digits That Add up to Target||44.2%|Hard||
|1450|Number of Students Doing Homework at a Given Time||77.1%|Easy||
|1451|Rearrange Words in a Sentence||59.7%|Medium||
|1451|Rearrange Words in a Sentence||59.8%|Medium||
|1452|People Whose List of Favorite Companies Is Not a Subset of Another List||55.1%|Medium||
|1453|Maximum Number of Darts Inside of a Circular Dartboard||35.5%|Hard||
|1454|Active Users||38.8%|Medium||
@ -1690,7 +1690,7 @@
|1549|The Most Recent Orders for Each Product||66.9%|Medium||
|1550|Three Consecutive Odds||64.5%|Easy||
|1551|Minimum Operations to Make Array Equal||77.8%|Medium||
|1552|Magnetic Force Between Two Balls||49.1%|Medium||
|1552|Magnetic Force Between Two Balls||49.2%|Medium||
|1553|Minimum Number of Days to Eat N Oranges||29.9%|Hard||
|1554|Strings Differ by One Character||63.7%|Medium||
|1555|Bank Account Summary||52.8%|Medium||
@ -1710,7 +1710,7 @@
|1569|Number of Ways to Reorder Array to Get Same BST||50.1%|Hard||
|1570|Dot Product of Two Sparse Vectors||91.2%|Medium||
|1571|Warehouse Manager||89.9%|Easy||
|1572|Matrix Diagonal Sum||77.7%|Easy||
|1572|Matrix Diagonal Sum||77.6%|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.3%|Medium||
|1574|Shortest Subarray to be Removed to Make Array Sorted||34.0%|Medium||
|1575|Count All Possible Routes||57.1%|Hard||
@ -1719,7 +1719,7 @@
|1578|Minimum Deletion Cost to Avoid Repeating Letters||60.5%|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||62.1%|Medium||
|1581|Customer Who Visited but Did Not Make Any Transactions||89.6%|Easy||
|1581|Customer Who Visited but Did Not Make Any Transactions||89.7%|Easy||
|1582|Special Positions in a Binary Matrix||64.3%|Easy||
|1583|Count Unhappy Friends||54.9%|Medium||
|1584|Min Cost to Connect All Points||52.7%|Medium||
@ -1766,7 +1766,7 @@
|1625|Lexicographically Smallest String After Applying Operations||64.1%|Medium||
|1626|Best Team With No Conflicts||38.3%|Medium||
|1627|Graph Connectivity With Threshold||39.6%|Hard||
|1628|Design an Expression Tree With Evaluate Function||79.7%|Medium||
|1628|Design an Expression Tree With Evaluate Function||79.6%|Medium||
|1629|Slowest Key|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1629.Slowest-Key)|59.1%|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)|49.9%|Medium||
@ -1785,8 +1785,8 @@
|1644|Lowest Common Ancestor of a Binary Tree II||56.1%|Medium||
|1645|Hopper Company Queries II||38.4%|Hard||
|1646|Get Maximum in Generated Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1646.Get-Maximum-in-Generated-Array)|53.3%|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.9%|Medium||
|1648|Sell Diminishing-Valued Colored Balls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1648.Sell-Diminishing-Valued-Colored-Balls)|30.6%|Medium||
|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)|55.0%|Medium||
|1648|Sell Diminishing-Valued Colored Balls|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1648.Sell-Diminishing-Valued-Colored-Balls)|30.5%|Medium||
|1649|Create Sorted Array through Instructions|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1649.Create-Sorted-Array-through-Instructions)|36.3%|Hard||
|1650|Lowest Common Ancestor of a Binary Tree III||76.6%|Medium||
|1651|Hopper Company Queries III||67.1%|Hard||
@ -1815,17 +1815,17 @@
|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.2%|Hard||
|1676|Lowest Common Ancestor of a Binary Tree IV||79.0%|Medium||
|1677|Product's Worth Over Invoices||73.3%|Easy||
|1677|Product's Worth Over Invoices||73.4%|Easy||
|1678|Goal Parser Interpretation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1678.Goal-Parser-Interpretation)|85.3%|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)|53.9%|Medium||
|1680|Concatenation of Consecutive Binary Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1680.Concatenation-of-Consecutive-Binary-Numbers)|52.3%|Medium||
|1681|Minimum Incompatibility|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1681.Minimum-Incompatibility)|35.7%|Hard||
|1682|Longest Palindromic Subsequence II||51.8%|Medium||
|1683|Invalid Tweets||90.9%|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)|82.0%|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)|82.1%|Easy||
|1685|Sum of Absolute Differences in a Sorted Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1685.Sum-of-Absolute-Differences-in-a-Sorted-Array)|62.9%|Medium||
|1686|Stone Game VI||49.9%|Medium||
|1687|Delivering Boxes from Storage to Ports||35.1%|Hard||
|1686|Stone Game VI||49.8%|Medium||
|1687|Delivering Boxes from Storage to Ports||35.0%|Hard||
|1688|Count of Matches in Tournament|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1688.Count-of-Matches-in-Tournament)|81.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.1%|Medium||
|1690|Stone Game VII|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1690.Stone-Game-VII)|48.7%|Medium||
@ -1856,13 +1856,13 @@
|1715|Count Apples and Oranges||79.1%|Medium||
|1716|Calculate Money in Leetcode Bank|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1716.Calculate-Money-in-Leetcode-Bank)|66.0%|Easy||
|1717|Maximum Score From Removing Substrings||40.6%|Medium||
|1718|Construct the Lexicographically Largest Valid Sequence||46.3%|Medium||
|1718|Construct the Lexicographically Largest Valid Sequence||46.4%|Medium||
|1719|Number Of Ways To Reconstruct A Tree||39.6%|Hard||
|1720|Decode XORed Array|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1720.Decode-XORed-Array)|85.2%|Easy||
|1721|Swapping Nodes in a Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1721.Swapping-Nodes-in-a-Linked-List)|68.0%|Medium||
|1721|Swapping Nodes in a Linked List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1721.Swapping-Nodes-in-a-Linked-List)|67.9%|Medium||
|1722|Minimize Hamming Distance After Swap Operations||54.2%|Medium||
|1723|Find Minimum Time to Finish All Jobs||43.7%|Hard||
|1724|Checking Existence of Edge Length Limited Paths II||57.0%|Hard||
|1724|Checking Existence of Edge Length Limited Paths II||57.1%|Hard||
|1725|Number Of Rectangles That Can Form The Largest Square|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1725.Number-Of-Rectangles-That-Can-Form-The-Largest-Square)|78.0%|Easy||
|1726|Tuple with Same Product||56.4%|Medium||
|1727|Largest Submatrix With Rearrangements||58.6%|Medium||
@ -1870,8 +1870,8 @@
|1729|Find Followers Count||71.4%|Easy||
|1730|Shortest Path to Get Food||56.4%|Medium||
|1731|The Number of Employees Which Report to Each Employee||49.1%|Easy||
|1732|Find the Highest Altitude|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1732.Find-the-Highest-Altitude)|80.1%|Easy||
|1733|Minimum Number of People to Teach||37.4%|Medium||
|1732|Find the Highest Altitude|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1732.Find-the-Highest-Altitude)|80.2%|Easy||
|1733|Minimum Number of People to Teach||37.3%|Medium||
|1734|Decode XORed Permutation||53.7%|Medium||
|1735|Count Ways to Make Array With Product||48.0%|Hard||
|1736|Latest Time by Replacing Hidden Digits|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1736.Latest-Time-by-Replacing-Hidden-Digits)|41.2%|Easy||
@ -1895,11 +1895,11 @@
|1754|Largest Merge Of Two Strings||40.4%|Medium||
|1755|Closest Subsequence Sum||35.7%|Hard||
|1756|Design Most Recently Used Queue||78.1%|Medium||
|1757|Recyclable and Low Fat Products||95.9%|Easy||
|1757|Recyclable and Low Fat Products||96.0%|Easy||
|1758|Minimum Changes To Make Alternating Binary String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1758.Minimum-Changes-To-Make-Alternating-Binary-String)|58.5%|Easy||
|1759|Count Number of Homogenous Substrings||42.3%|Medium||
|1760|Minimum Limit of Balls in a Bag||52.6%|Medium||
|1761|Minimum Degree of a Connected Trio in a Graph||37.3%|Hard||
|1761|Minimum Degree of a Connected Trio in a Graph||37.4%|Hard||
|1762|Buildings With an Ocean View||80.7%|Medium||
|1763|Longest Nice Substring||61.4%|Easy||
|1764|Form Array by Concatenating Subarrays of Another Array||55.0%|Medium||
@ -1910,17 +1910,17 @@
|1769|Minimum Number of Operations to Move All Balls to Each Box||87.3%|Medium||
|1770|Maximum Score from Performing Multiplication Operations||29.2%|Medium||
|1771|Maximize Palindrome Length From Subsequences||34.1%|Hard||
|1772|Sort Features by Popularity||64.8%|Medium||
|1772|Sort Features by Popularity||65.0%|Medium||
|1773|Count Items Matching a Rule||85.4%|Easy||
|1774|Closest Dessert Cost||58.8%|Medium||
|1775|Equal Sum Arrays With Minimum Number of Operations||50.6%|Medium||
|1775|Equal Sum Arrays With Minimum Number of Operations||50.7%|Medium||
|1776|Car Fleet II||45.2%|Hard||
|1777|Product's Price for Each Store||87.4%|Easy||
|1777|Product's Price for Each Store||87.3%|Easy||
|1778|Shortest Path in a Hidden Grid||46.7%|Medium||
|1779|Find Nearest Point That Has the Same X or Y Coordinate||67.8%|Easy||
|1779|Find Nearest Point That Has the Same X or Y Coordinate||67.7%|Easy||
|1780|Check if Number is a Sum of Powers of Three||63.3%|Medium||
|1781|Sum of Beauty of All Substrings||57.3%|Medium||
|1782|Count Pairs Of Nodes||31.8%|Hard||
|1782|Count Pairs Of Nodes||31.9%|Hard||
|1783|Grand Slam Titles||90.8%|Medium||
|1784|Check if Binary String Has at Most One Segment of Ones||41.6%|Easy||
|1785|Minimum Elements to Add to Form a Given Sum||39.1%|Medium||
@ -1928,21 +1928,21 @@
|1787|Make the XOR of All Segments Equal to Zero||36.1%|Hard||
|1788|Maximize the Beauty of the Garden||69.3%|Hard||
|1789|Primary Department for Each Employee||79.6%|Easy||
|1790|Check if One String Swap Can Make Strings Equal||62.8%|Easy||
|1790|Check if One String Swap Can Make Strings Equal||62.7%|Easy||
|1791|Find Center of Star Graph||85.0%|Medium||
|1792|Maximum Average Pass Ratio||56.5%|Medium||
|1793|Maximum Score of a Good Subarray||45.6%|Hard||
|1794|Count Pairs of Equal Substrings With Minimum Difference||68.1%|Medium||
|1793|Maximum Score of a Good Subarray||45.5%|Hard||
|1794|Count Pairs of Equal Substrings With Minimum Difference||68.2%|Medium||
|1795|Rearrange Products Table||91.8%|Easy||
|1796|Second Largest Digit in a String||47.9%|Easy||
|1797|Design Authentication Manager||47.7%|Medium||
|1798|Maximum Number of Consecutive Values You Can Make||42.2%|Medium||
|1798|Maximum Number of Consecutive Values You Can Make||42.3%|Medium||
|1799|Maximize Score After N Operations||51.8%|Hard||
|1800|Maximum Ascending Subarray Sum||66.0%|Easy||
|1801|Number of Orders in the Backlog||43.5%|Medium||
|1801|Number of Orders in the Backlog||43.6%|Medium||
|1802|Maximum Value at a Given Index in a Bounded Array||26.5%|Medium||
|1803|Count Pairs With XOR in a Range||40.6%|Hard||
|1804|Implement Trie II (Prefix Tree)||64.6%|Medium||
|1804|Implement Trie II (Prefix Tree)||63.2%|Medium||
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|
------------------------------------------------------------------

View File

@ -0,0 +1,45 @@
package leetcode
import "math"
func pacificAtlantic(matrix [][]int) [][]int {
if len(matrix) == 0 || len(matrix[0]) == 0 {
return nil
}
row, col, res := len(matrix), len(matrix[0]), make([][]int, 0)
pacific, atlantic := make([][]bool, row), make([][]bool, row)
for i := 0; i < row; i++ {
pacific[i] = make([]bool, col)
atlantic[i] = make([]bool, col)
}
for i := 0; i < row; i++ {
dfs(matrix, i, 0, &pacific, math.MinInt32)
dfs(matrix, i, col-1, &atlantic, math.MinInt32)
}
for j := 0; j < col; j++ {
dfs(matrix, 0, j, &pacific, math.MinInt32)
dfs(matrix, row-1, j, &atlantic, math.MinInt32)
}
for i := 0; i < row; i++ {
for j := 0; j < col; j++ {
if atlantic[i][j] && pacific[i][j] {
res = append(res, []int{i, j})
}
}
}
return res
}
func dfs(matrix [][]int, row, col int, visited *[][]bool, height int) {
if row < 0 || row >= len(matrix) || col < 0 || col >= len(matrix[0]) {
return
}
if (*visited)[row][col] || matrix[row][col] < height {
return
}
(*visited)[row][col] = true
dfs(matrix, row+1, col, visited, matrix[row][col])
dfs(matrix, row-1, col, visited, matrix[row][col])
dfs(matrix, row, col+1, visited, matrix[row][col])
dfs(matrix, row, col-1, visited, matrix[row][col])
}

View File

@ -0,0 +1,56 @@
package leetcode
import (
"fmt"
"testing"
)
type question417 struct {
para417
ans417
}
// para 是参数
// one 代表第一个参数
type para417 struct {
matrix [][]int
}
// ans 是答案
// one 代表第一个答案
type ans417 struct {
one [][]int
}
func Test_Problem417(t *testing.T) {
qs := []question417{
{
para417{[][]int{
{1, 2, 2, 3, 5},
{3, 2, 3, 4, 4},
{2, 4, 5, 3, 1},
{6, 7, 1, 4, 5},
{5, 1, 1, 2, 4},
}},
ans417{[][]int{
{0, 4},
{1, 3},
{1, 4},
{2, 2},
{3, 0},
{3, 1},
{4, 0},
}},
},
}
fmt.Printf("------------------------Leetcode Problem 417------------------------\n")
for _, q := range qs {
_, p := q.ans417, q.para417
fmt.Printf("【input】:%v 【output】:%v\n", p, pacificAtlantic(p.matrix))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,92 @@
# [417. Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/)
## 题目
Given an `m x n` matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.
Water can only flow in four directions (up, down, left, or right) from a cell to another one with height equal or lower.
Find the list of grid coordinates where water can flow to both the Pacific and Atlantic ocean.
**Note:**
1. The order of returned grid coordinates does not matter.
2. Both m and n are less than 150.
**Example:**
```
Given the following 5x5 matrix:
Pacific ~ ~ ~ ~ ~
~ 1 2 2 3 (5) *
~ 3 2 3 (4) (4) *
~ 2 4 (5) 3 1 *
~ (6) (7) 1 4 5 *
~ (5) 1 1 2 4 *
* * * * * Atlantic
Return:
[[0, 4], [1, 3], [1, 4], [2, 2], [3, 0], [3, 1], [4, 0]] (positions with parentheses in above matrix).
```
## 题目大意
给定一个 m x n 的非负整数矩阵来表示一片大陆上各个单元格的高度。“太平洋”处于大陆的左边界和上边界,而“大西洋”处于大陆的右边界和下边界。规定水流只能按照上、下、左、右四个方向流动,且只能从高到低或者在同等高度上流动。请找出那些水流既可以流动到“太平洋”,又能流动到“大西洋”的陆地单元的坐标。
## 解题思路
- 暴力解法,利用 DFS 把二维数据按照行优先搜索一遍,分别标记出太平洋和大西洋水流能到达的位置。再按照列优先搜索一遍,标记出太平洋和大西洋水流能到达的位置。最后两者都能到达的坐标即为所求。
## 代码
```go
package leetcode
import "math"
func pacificAtlantic(matrix [][]int) [][]int {
if len(matrix) == 0 || len(matrix[0]) == 0 {
return nil
}
row, col, res := len(matrix), len(matrix[0]), make([][]int, 0)
pacific, atlantic := make([][]bool, row), make([][]bool, row)
for i := 0; i < row; i++ {
pacific[i] = make([]bool, col)
atlantic[i] = make([]bool, col)
}
for i := 0; i < row; i++ {
dfs(matrix, i, 0, &pacific, math.MinInt32)
dfs(matrix, i, col-1, &atlantic, math.MinInt32)
}
for j := 0; j < col; j++ {
dfs(matrix, 0, j, &pacific, math.MinInt32)
dfs(matrix, row-1, j, &atlantic, math.MinInt32)
}
for i := 0; i < row; i++ {
for j := 0; j < col; j++ {
if atlantic[i][j] && pacific[i][j] {
res = append(res, []int{i, j})
}
}
}
return res
}
func dfs(matrix [][]int, row, col int, visited *[][]bool, height int) {
if row < 0 || row >= len(matrix) || col < 0 || col >= len(matrix[0]) {
return
}
if (*visited)[row][col] || matrix[row][col] < height {
return
}
(*visited)[row][col] = true
dfs(matrix, row+1, col, visited, matrix[row][col])
dfs(matrix, row-1, col, visited, matrix[row][col])
dfs(matrix, row, col+1, visited, matrix[row][col])
dfs(matrix, row, col-1, visited, matrix[row][col])
}
```

View File

@ -0,0 +1,36 @@
package leetcode
func wordSubsets(A []string, B []string) []string {
var counter [26]int
for _, b := range B {
var m [26]int
for _, c := range b {
j := c - 'a'
m[j]++
}
for i := 0; i < 26; i++ {
if m[i] > counter[i] {
counter[i] = m[i]
}
}
}
var res []string
for _, a := range A {
var m [26]int
for _, c := range a {
j := c - 'a'
m[j]++
}
ok := true
for i := 0; i < 26; i++ {
if m[i] < counter[i] {
ok = false
break
}
}
if ok {
res = append(res, a)
}
}
return res
}

View File

@ -0,0 +1,63 @@
package leetcode
import (
"fmt"
"testing"
)
type question916 struct {
para916
ans916
}
// para 是参数
// one 代表第一个参数
type para916 struct {
A []string
B []string
}
// ans 是答案
// one 代表第一个答案
type ans916 struct {
one []string
}
func Test_Problem916(t *testing.T) {
qs := []question916{
{
para916{[]string{"amazon", "apple", "facebook", "google", "leetcode"}, []string{"e", "o"}},
ans916{[]string{"facebook", "google", "leetcode"}},
},
{
para916{[]string{"amazon", "apple", "facebook", "google", "leetcode"}, []string{"l", "e"}},
ans916{[]string{"apple", "google", "leetcode"}},
},
{
para916{[]string{"amazon", "apple", "facebook", "google", "leetcode"}, []string{"e", "oo"}},
ans916{[]string{"facebook", "google"}},
},
{
para916{[]string{"amazon", "apple", "facebook", "google", "leetcode"}, []string{"lo", "eo"}},
ans916{[]string{"google", "leetcode"}},
},
{
para916{[]string{"amazon", "apple", "facebook", "google", "leetcode"}, []string{"ec", "oc", "ceo"}},
ans916{[]string{"facebook", "leetcode"}},
},
}
fmt.Printf("------------------------Leetcode Problem 916------------------------\n")
for _, q := range qs {
_, p := q.ans916, q.para916
fmt.Printf("【input】:%v 【output】:%v\n", p, wordSubsets(p.A, p.B))
}
fmt.Printf("\n\n\n")
}

View File

@ -0,0 +1,103 @@
# [916. Word Subsets](https://leetcode.com/problems/word-subsets/)
## 题目
We are given two arrays `A` and `B` of words.  Each word is a string of lowercase letters.
Now, say that word `b` is a subset of word `a` ****if every letter in `b` occurs in `a`, **including multiplicity**.  For example, `"wrr"` is a subset of `"warrior"`, but is not a subset of `"world"`.
Now say a word `a` from `A` is *universal* if for every `b` in `B`, `b` is a subset of `a`.
Return a list of all universal words in `A`.  You can return the words in any order.
**Example 1:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["e","o"]
Output:["facebook","google","leetcode"]
```
**Example 2:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["l","e"]
Output:["apple","google","leetcode"]
```
**Example 3:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["e","oo"]
Output:["facebook","google"]
```
**Example 4:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["lo","eo"]
Output:["google","leetcode"]
```
**Example 5:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["ec","oc","ceo"]
Output:["facebook","leetcode"]
```
**Note:**
1. `1 <= A.length, B.length <= 10000`
2. `1 <= A[i].length, B[i].length <= 10`
3. `A[i]` and `B[i]` consist only of lowercase letters.
4. All words in `A[i]` are unique: there isn't `i != j` with `A[i] == A[j]`.
## 题目大意
我们给出两个单词数组 A  B。每个单词都是一串小写字母。现在如果 b 中的每个字母都出现在 a 中,包括重复出现的字母,那么称单词 b 是单词 a 的子集。 例如“wrr” 是 “warrior” 的子集,但不是 “world” 的子集。如果对 B 中的每一个单词 bb 都是 a 的子集那么我们称 A 中的单词 a 是通用的。你可以按任意顺序以列表形式返回 A 中所有的通用单词。
## 解题思路
- 简单题。先统计出 B 数组中单词每个字母的频次,再在 A 数组中依次判断每个单词是否超过了这个频次,如果超过了即输出。
## 代码
```go
package leetcode
func wordSubsets(A []string, B []string) []string {
var counter [26]int
for _, b := range B {
var m [26]int
for _, c := range b {
j := c - 'a'
m[j]++
}
for i := 0; i < 26; i++ {
if m[i] > counter[i] {
counter[i] = m[i]
}
}
}
var res []string
for _, a := range A {
var m [26]int
for _, c := range a {
j := c - 'a'
m[j]++
}
ok := true
for i := 0; i < 26; i++ {
if m[i] < counter[i] {
ok = false
break
}
}
if ok {
res = append(res, a)
}
}
return res
}
```

View File

@ -79,5 +79,5 @@ func canPartition(nums []int) bool {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0414.Third-Maximum-Number/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0421.Maximum-XOR-of-Two-Numbers-in-an-Array/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0417.Pacific-Atlantic-Water-Flow/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,99 @@
# [417. Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/)
## 题目
Given an `m x n` matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.
Water can only flow in four directions (up, down, left, or right) from a cell to another one with height equal or lower.
Find the list of grid coordinates where water can flow to both the Pacific and Atlantic ocean.
**Note:**
1. The order of returned grid coordinates does not matter.
2. Both m and n are less than 150.
**Example:**
```
Given the following 5x5 matrix:
Pacific ~ ~ ~ ~ ~
~ 1 2 2 3 (5) *
~ 3 2 3 (4) (4) *
~ 2 4 (5) 3 1 *
~ (6) (7) 1 4 5 *
~ (5) 1 1 2 4 *
* * * * * Atlantic
Return:
[[0, 4], [1, 3], [1, 4], [2, 2], [3, 0], [3, 1], [4, 0]] (positions with parentheses in above matrix).
```
## 题目大意
给定一个 m x n 的非负整数矩阵来表示一片大陆上各个单元格的高度。“太平洋”处于大陆的左边界和上边界,而“大西洋”处于大陆的右边界和下边界。规定水流只能按照上、下、左、右四个方向流动,且只能从高到低或者在同等高度上流动。请找出那些水流既可以流动到“太平洋”,又能流动到“大西洋”的陆地单元的坐标。
## 解题思路
- 暴力解法,利用 DFS 把二维数据按照行优先搜索一遍,分别标记出太平洋和大西洋水流能到达的位置。再按照列优先搜索一遍,标记出太平洋和大西洋水流能到达的位置。最后两者都能到达的坐标即为所求。
## 代码
```go
package leetcode
import "math"
func pacificAtlantic(matrix [][]int) [][]int {
if len(matrix) == 0 || len(matrix[0]) == 0 {
return nil
}
row, col, res := len(matrix), len(matrix[0]), make([][]int, 0)
pacific, atlantic := make([][]bool, row), make([][]bool, row)
for i := 0; i < row; i++ {
pacific[i] = make([]bool, col)
atlantic[i] = make([]bool, col)
}
for i := 0; i < row; i++ {
dfs(matrix, i, 0, &pacific, math.MinInt32)
dfs(matrix, i, col-1, &atlantic, math.MinInt32)
}
for j := 0; j < col; j++ {
dfs(matrix, 0, j, &pacific, math.MinInt32)
dfs(matrix, row-1, j, &atlantic, math.MinInt32)
}
for i := 0; i < row; i++ {
for j := 0; j < col; j++ {
if atlantic[i][j] && pacific[i][j] {
res = append(res, []int{i, j})
}
}
}
return res
}
func dfs(matrix [][]int, row, col int, visited *[][]bool, height int) {
if row < 0 || row >= len(matrix) || col < 0 || col >= len(matrix[0]) {
return
}
if (*visited)[row][col] || matrix[row][col] < height {
return
}
(*visited)[row][col] = true
dfs(matrix, row+1, col, visited, matrix[row][col])
dfs(matrix, row-1, col, visited, matrix[row][col])
dfs(matrix, row, col+1, visited, matrix[row][col])
dfs(matrix, row, col-1, visited, matrix[row][col])
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0416.Partition-Equal-Subset-Sum/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0421.Maximum-XOR-of-Two-Numbers-in-an-Array/">下一页➡️</a></p>
</div>

View File

@ -101,6 +101,6 @@ func findMaximumXOR1(nums []int) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0416.Partition-Equal-Subset-Sum/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0417.Pacific-Atlantic-Water-Flow/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0400~0499/0424.Longest-Repeating-Character-Replacement/">下一页➡️</a></p>
</div>

View File

@ -108,5 +108,5 @@ func gcd(a, b int) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0911.Online-Election/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0918.Maximum-Sum-Circular-Subarray/">下一页➡️</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0916.Word-Subsets/">下一页➡️</a></p>
</div>

View File

@ -0,0 +1,110 @@
# [916. Word Subsets](https://leetcode.com/problems/word-subsets/)
## 题目
We are given two arrays `A` and `B` of words.  Each word is a string of lowercase letters.
Now, say that word `b` is a subset of word `a` ****if every letter in `b` occurs in `a`, **including multiplicity**.  For example, `"wrr"` is a subset of `"warrior"`, but is not a subset of `"world"`.
Now say a word `a` from `A` is *universal* if for every `b` in `B`, `b` is a subset of `a`.
Return a list of all universal words in `A`.  You can return the words in any order.
**Example 1:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["e","o"]
Output:["facebook","google","leetcode"]
```
**Example 2:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["l","e"]
Output:["apple","google","leetcode"]
```
**Example 3:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["e","oo"]
Output:["facebook","google"]
```
**Example 4:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["lo","eo"]
Output:["google","leetcode"]
```
**Example 5:**
```
Input:A = ["amazon","apple","facebook","google","leetcode"], B = ["ec","oc","ceo"]
Output:["facebook","leetcode"]
```
**Note:**
1. `1 <= A.length, B.length <= 10000`
2. `1 <= A[i].length, B[i].length <= 10`
3. `A[i]` and `B[i]` consist only of lowercase letters.
4. All words in `A[i]` are unique: there isn't `i != j` with `A[i] == A[j]`.
## 题目大意
我们给出两个单词数组 A  B。每个单词都是一串小写字母。现在如果 b 中的每个字母都出现在 a 中,包括重复出现的字母,那么称单词 b 是单词 a 的子集。 例如“wrr” 是 “warrior” 的子集,但不是 “world” 的子集。如果对 B 中的每一个单词 bb 都是 a 的子集那么我们称 A 中的单词 a 是通用的。你可以按任意顺序以列表形式返回 A 中所有的通用单词。
## 解题思路
- 简单题。先统计出 B 数组中单词每个字母的频次,再在 A 数组中依次判断每个单词是否超过了这个频次,如果超过了即输出。
## 代码
```go
package leetcode
func wordSubsets(A []string, B []string) []string {
var counter [26]int
for _, b := range B {
var m [26]int
for _, c := range b {
j := c - 'a'
m[j]++
}
for i := 0; i < 26; i++ {
if m[i] > counter[i] {
counter[i] = m[i]
}
}
}
var res []string
for _, a := range A {
var m [26]int
for _, c := range a {
j := c - 'a'
m[j]++
}
ok := true
for i := 0; i < 26; i++ {
if m[i] < counter[i] {
ok = false
break
}
}
if ok {
res = append(res, a)
}
}
return res
}
```
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0914.X-of-a-Kind-in-a-Deck-of-Cards/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0918.Maximum-Sum-Circular-Subarray/">下一页➡️</a></p>
</div>

View File

@ -103,6 +103,6 @@ func kadane(a []int) int {
----------------------------------------------
<div style="display: flex;justify-content: space-between;align-items: center;">
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0914.X-of-a-Kind-in-a-Deck-of-Cards/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0916.Word-Subsets/">⬅️上一页</a></p>
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0900~0999/0920.Number-of-Music-Playlists/">下一页➡️</a></p>
</div>

View File

@ -108,7 +108,7 @@ weight: 1
|0914|X of a Kind in a Deck of Cards|[Go]({{< relref "/ChapterFour/0900~0999/0914.X-of-a-Kind-in-a-Deck-of-Cards.md" >}})|Easy||||34.1%|
|0918|Maximum Sum Circular Subarray|[Go]({{< relref "/ChapterFour/0900~0999/0918.Maximum-Sum-Circular-Subarray.md" >}})|Medium||||34.3%|
|0922|Sort Array By Parity II|[Go]({{< relref "/ChapterFour/0900~0999/0922.Sort-Array-By-Parity-II.md" >}})|Easy| O(n)| O(1)||70.6%|
|0969|Pancake Sorting|[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})|Medium| O(n)| O(1)|❤️|68.8%|
|0969|Pancake Sorting|[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})|Medium| O(n)| O(1)|❤️|68.7%|
|0977|Squares of a Sorted Array|[Go]({{< relref "/ChapterFour/0900~0999/0977.Squares-of-a-Sorted-Array.md" >}})|Easy| O(n)| O(1)||71.9%|
|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%|
@ -158,13 +158,13 @@ weight: 1
|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||||54.9%|
|1608|Special Array With X Elements Greater Than or Equal X|[Go]({{< relref "/ChapterFour/1600~1699/1608.Special-Array-With-X-Elements-Greater-Than-or-Equal-X.md" >}})|Easy||||61.3%|
|1619|Mean of Array After Removing Some Elements|[Go]({{< relref "/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements.md" >}})|Easy||||64.7%|
|1619|Mean of Array After Removing Some Elements|[Go]({{< relref "/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements.md" >}})|Easy||||64.8%|
|1629|Slowest Key|[Go]({{< relref "/ChapterFour/1600~1699/1629.Slowest-Key.md" >}})|Easy||||59.1%|
|1636|Sort Array by Increasing Frequency|[Go]({{< relref "/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency.md" >}})|Easy||||66.7%|
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||59.8%|
|1646|Get Maximum in Generated Array|[Go]({{< relref "/ChapterFour/1600~1699/1646.Get-Maximum-in-Generated-Array.md" >}})|Easy||||53.3%|
|1652|Defuse the Bomb|[Go]({{< relref "/ChapterFour/1600~1699/1652.Defuse-the-Bomb.md" >}})|Easy||||62.1%|
|1656|Design an Ordered Stream|[Go]({{< relref "/ChapterFour/1600~1699/1656.Design-an-Ordered-Stream.md" >}})|Easy||||81.9%|
|1656|Design an Ordered Stream|[Go]({{< relref "/ChapterFour/1600~1699/1656.Design-an-Ordered-Stream.md" >}})|Easy||||82.0%|
|1672|Richest Customer Wealth|[Go]({{< relref "/ChapterFour/1600~1699/1672.Richest-Customer-Wealth.md" >}})|Easy||||88.2%|
|1700|Number of Students Unable to Eat Lunch|[Go]({{< relref "/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md" >}})|Easy||||68.0%|
|1732|Find the Highest Altitude|[Go]({{< relref "/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md" >}})|Easy||||80.1%|

View File

@ -21,6 +21,7 @@ weight: 10
|0200|Number of Islands|[Go]({{< relref "/ChapterFour/0200~0299/0200.Number-of-Islands.md" >}})|Medium| O(n^2)| O(n^2)||49.4%|
|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.8%|
|0417|Pacific Atlantic Water Flow|[Go]({{< relref "/ChapterFour/0400~0499/0417.Pacific-Atlantic-Water-Flow.md" >}})|Medium||||43.8%|
|0513|Find Bottom Left Tree Value|[Go]({{< relref "/ChapterFour/0500~0599/0513.Find-Bottom-Left-Tree-Value.md" >}})|Medium||||62.8%|
|0515|Find Largest Value in Each Tree Row|[Go]({{< relref "/ChapterFour/0500~0599/0515.Find-Largest-Value-in-Each-Tree-Row.md" >}})|Medium| O(n)| O(n)||62.3%|
|0529|Minesweeper|[Go]({{< relref "/ChapterFour/0500~0599/0529.Minesweeper.md" >}})|Medium||||61.4%|

View File

@ -37,6 +37,7 @@ weight: 9
|0329|Longest Increasing Path in a Matrix|[Go]({{< relref "/ChapterFour/0300~0399/0329.Longest-Increasing-Path-in-a-Matrix.md" >}})|Hard||||45.2%|
|0337|House Robber III|[Go]({{< relref "/ChapterFour/0300~0399/0337.House-Robber-III.md" >}})|Medium||||52.0%|
|0394|Decode String|[Go]({{< relref "/ChapterFour/0300~0399/0394.Decode-String.md" >}})|Medium| O(n)| O(n)||52.9%|
|0417|Pacific Atlantic Water Flow|[Go]({{< relref "/ChapterFour/0400~0499/0417.Pacific-Atlantic-Water-Flow.md" >}})|Medium||||43.8%|
|0491|Increasing Subsequences|[Go]({{< relref "/ChapterFour/0400~0499/0491.Increasing-Subsequences.md" >}})|Medium||||47.6%|
|0494|Target Sum|[Go]({{< relref "/ChapterFour/0400~0499/0494.Target-Sum.md" >}})|Medium||||45.7%|
|0513|Find Bottom Left Tree Value|[Go]({{< relref "/ChapterFour/0500~0599/0513.Find-Bottom-Left-Tree-Value.md" >}})|Medium||||62.8%|

View File

@ -34,7 +34,7 @@ weight: 13
|0350|Intersection of Two Arrays II|[Go]({{< relref "/ChapterFour/0300~0399/0350.Intersection-of-Two-Arrays-II.md" >}})|Easy| O(n)| O(n) ||52.0%|
|0387|First Unique Character in a String|[Go]({{< relref "/ChapterFour/0300~0399/0387.First-Unique-Character-in-a-String.md" >}})|Easy||||53.8%|
|0389|Find the Difference|[Go]({{< relref "/ChapterFour/0300~0399/0389.Find-the-Difference.md" >}})|Easy||||57.9%|
|0409|Longest Palindrome|[Go]({{< relref "/ChapterFour/0400~0499/0409.Longest-Palindrome.md" >}})|Easy||||52.2%|
|0409|Longest Palindrome|[Go]({{< relref "/ChapterFour/0400~0499/0409.Longest-Palindrome.md" >}})|Easy||||52.3%|
|0438|Find All Anagrams in a String|[Go]({{< relref "/ChapterFour/0400~0499/0438.Find-All-Anagrams-in-a-String.md" >}})|Medium| O(n)| O(1) ||45.1%|
|0447|Number of Boomerangs|[Go]({{< relref "/ChapterFour/0400~0499/0447.Number-of-Boomerangs.md" >}})|Medium| O(n)| O(1) ||52.5%|
|0451|Sort Characters By Frequency|[Go]({{< relref "/ChapterFour/0400~0499/0451.Sort-Characters-By-Frequency.md" >}})|Medium| O(n log n)| O(1) ||64.5%|
@ -50,7 +50,7 @@ weight: 13
|0645|Set Mismatch|[Go]({{< relref "/ChapterFour/0600~0699/0645.Set-Mismatch.md" >}})|Easy||||41.4%|
|0648|Replace Words|[Go]({{< relref "/ChapterFour/0600~0699/0648.Replace-Words.md" >}})|Medium| O(n)| O(n) ||58.8%|
|0676|Implement Magic Dictionary|[Go]({{< relref "/ChapterFour/0600~0699/0676.Implement-Magic-Dictionary.md" >}})|Medium| O(n)| O(n) ||55.3%|
|0705|Design HashSet|[Go]({{< relref "/ChapterFour/0700~0799/0705.Design-HashSet.md" >}})|Easy||||64.6%|
|0705|Design HashSet|[Go]({{< relref "/ChapterFour/0700~0799/0705.Design-HashSet.md" >}})|Easy||||64.5%|
|0706|Design HashMap|[Go]({{< relref "/ChapterFour/0700~0799/0706.Design-HashMap.md" >}})|Easy||||64.2%|
|0710|Random Pick with Blacklist|[Go]({{< relref "/ChapterFour/0700~0799/0710.Random-Pick-with-Blacklist.md" >}})|Hard| O(n)| O(n) ||33.0%|
|0718|Maximum Length of Repeated Subarray|[Go]({{< relref "/ChapterFour/0700~0799/0718.Maximum-Length-of-Repeated-Subarray.md" >}})|Medium||||50.4%|
@ -64,7 +64,7 @@ weight: 13
|0884|Uncommon Words from Two Sentences|[Go]({{< relref "/ChapterFour/0800~0899/0884.Uncommon-Words-from-Two-Sentences.md" >}})|Easy||||64.2%|
|0895|Maximum Frequency Stack|[Go]({{< relref "/ChapterFour/0800~0899/0895.Maximum-Frequency-Stack.md" >}})|Hard| O(n)| O(n) ||63.2%|
|0930|Binary Subarrays With Sum|[Go]({{< relref "/ChapterFour/0900~0999/0930.Binary-Subarrays-With-Sum.md" >}})|Medium| O(n)| O(n) |❤️|44.7%|
|0953|Verifying an Alien Dictionary|[Go]({{< relref "/ChapterFour/0900~0999/0953.Verifying-an-Alien-Dictionary.md" >}})|Easy||||51.8%|
|0953|Verifying an Alien Dictionary|[Go]({{< relref "/ChapterFour/0900~0999/0953.Verifying-an-Alien-Dictionary.md" >}})|Easy||||51.9%|
|0961|N-Repeated Element in Size 2N Array|[Go]({{< relref "/ChapterFour/0900~0999/0961.N-Repeated-Element-in-Size-2N-Array.md" >}})|Easy||||74.6%|
|0966|Vowel Spellchecker|[Go]({{< relref "/ChapterFour/0900~0999/0966.Vowel-Spellchecker.md" >}})|Medium||||51.9%|
|0970|Powerful Integers|[Go]({{< relref "/ChapterFour/0900~0999/0970.Powerful-Integers.md" >}})|Medium||||40.0%|

View File

@ -57,7 +57,7 @@ weight: 4
|1290|Convert Binary Number in a Linked List to Integer|[Go]({{< relref "/ChapterFour/1200~1299/1290.Convert-Binary-Number-in-a-Linked-List-to-Integer.md" >}})|Easy||||81.8%|
|1669|Merge In Between Linked Lists|[Go]({{< relref "/ChapterFour/1600~1699/1669.Merge-In-Between-Linked-Lists.md" >}})|Medium||||75.9%|
|1670|Design Front Middle Back Queue|[Go]({{< relref "/ChapterFour/1600~1699/1670.Design-Front-Middle-Back-Queue.md" >}})|Medium||||54.2%|
|1721|Swapping Nodes in a Linked List|[Go]({{< relref "/ChapterFour/1700~1799/1721.Swapping-Nodes-in-a-Linked-List.md" >}})|Medium||||68.0%|
|1721|Swapping Nodes in a Linked List|[Go]({{< relref "/ChapterFour/1700~1799/1721.Swapping-Nodes-in-a-Linked-List.md" >}})|Medium||||67.9%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -85,7 +85,7 @@ weight: 12
|1317|Convert Integer to the Sum of Two No-Zero Integers|[Go]({{< relref "/ChapterFour/1300~1399/1317.Convert-Integer-to-the-Sum-of-Two-No-Zero-Integers.md" >}})|Easy||||56.8%|
|1512|Number of Good Pairs|[Go]({{< relref "/ChapterFour/1500~1599/1512.Number-of-Good-Pairs.md" >}})|Easy||||87.7%|
|1641|Count Sorted Vowel Strings|[Go]({{< relref "/ChapterFour/1600~1699/1641.Count-Sorted-Vowel-Strings.md" >}})|Medium||||76.0%|
|1648|Sell Diminishing-Valued Colored Balls|[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})|Medium||||30.6%|
|1648|Sell Diminishing-Valued Colored Balls|[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})|Medium||||30.5%|
|1680|Concatenation of Consecutive Binary Numbers|[Go]({{< relref "/ChapterFour/1600~1699/1680.Concatenation-of-Consecutive-Binary-Numbers.md" >}})|Medium||||52.3%|
|1685|Sum of Absolute Differences in a Sorted Array|[Go]({{< relref "/ChapterFour/1600~1699/1685.Sum-of-Absolute-Differences-in-a-Sorted-Array.md" >}})|Medium||||62.9%|
|1716|Calculate Money in Leetcode Bank|[Go]({{< relref "/ChapterFour/1700~1799/1716.Calculate-Money-in-Leetcode-Bank.md" >}})|Easy||||66.0%|

View File

@ -39,7 +39,7 @@ weight: 14
|0767|Reorganize String|[Go]({{< relref "/ChapterFour/0700~0799/0767.Reorganize-String.md" >}})|Medium| O(n log n)| O(log n) |❤️|50.2%|
|0853|Car Fleet|[Go]({{< relref "/ChapterFour/0800~0899/0853.Car-Fleet.md" >}})|Medium| O(n log n)| O(log n) ||44.2%|
|0922|Sort Array By Parity II|[Go]({{< relref "/ChapterFour/0900~0999/0922.Sort-Array-By-Parity-II.md" >}})|Easy| O(n)| O(1) ||70.6%|
|0969|Pancake Sorting|[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})|Medium| O(n log n)| O(log n) |❤️|68.8%|
|0969|Pancake Sorting|[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})|Medium| O(n log n)| O(log n) |❤️|68.7%|
|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.8%|
|1030|Matrix Cells in Distance Order|[Go]({{< relref "/ChapterFour/1000~1099/1030.Matrix-Cells-in-Distance-Order.md" >}})|Easy| O(n^2)| O(1) ||67.4%|
@ -50,8 +50,8 @@ weight: 14
|1329|Sort the Matrix Diagonally|[Go]({{< relref "/ChapterFour/1300~1399/1329.Sort-the-Matrix-Diagonally.md" >}})|Medium||||81.7%|
|1636|Sort Array by Increasing Frequency|[Go]({{< relref "/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency.md" >}})|Easy||||66.7%|
|1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||59.8%|
|1647|Minimum Deletions to Make Character Frequencies Unique|[Go]({{< relref "/ChapterFour/1600~1699/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique.md" >}})|Medium||||54.9%|
|1648|Sell Diminishing-Valued Colored Balls|[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})|Medium||||30.6%|
|1647|Minimum Deletions to Make Character Frequencies Unique|[Go]({{< relref "/ChapterFour/1600~1699/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique.md" >}})|Medium||||55.0%|
|1648|Sell Diminishing-Valued Colored Balls|[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})|Medium||||30.5%|
|1691|Maximum Height by Stacking Cuboids|[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})|Hard||||50.1%|
|1710|Maximum Units on a Truck|[Go]({{< relref "/ChapterFour/1700~1799/1710.Maximum-Units-on-a-Truck.md" >}})|Easy||||69.9%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -34,7 +34,7 @@ weight: 5
|0232|Implement Queue using Stacks|[Go]({{< relref "/ChapterFour/0200~0299/0232.Implement-Queue-using-Stacks.md" >}})|Easy| O(n)| O(n)||52.5%|
|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.1%|
|0341|Flatten Nested List Iterator|[Go]({{< relref "/ChapterFour/0300~0399/0341.Flatten-Nested-List-Iterator.md" >}})|Medium||||54.7%|
|0385|Mini Parser|[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})|Medium||||34.5%|
|0385|Mini Parser|[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})|Medium||||34.6%|
|0394|Decode String|[Go]({{< relref "/ChapterFour/0300~0399/0394.Decode-String.md" >}})|Medium| O(n)| O(n)||52.9%|
|0402|Remove K Digits|[Go]({{< relref "/ChapterFour/0400~0499/0402.Remove-K-Digits.md" >}})|Medium| O(n)| O(1)||28.7%|
|0456|132 Pattern|[Go]({{< relref "/ChapterFour/0400~0499/0456.132-Pattern.md" >}})|Medium| O(n)| O(n)||30.7%|
@ -58,7 +58,7 @@ weight: 5
|1021|Remove Outermost Parentheses|[Go]({{< relref "/ChapterFour/1000~1099/1021.Remove-Outermost-Parentheses.md" >}})|Easy| O(n)| O(1)||79.2%|
|1047|Remove All Adjacent Duplicates In String|[Go]({{< relref "/ChapterFour/1000~1099/1047.Remove-All-Adjacent-Duplicates-In-String.md" >}})|Easy| O(n)| O(1)||71.1%|
|1249|Minimum Remove to Make Valid Parentheses|[Go]({{< relref "/ChapterFour/1200~1299/1249.Minimum-Remove-to-Make-Valid-Parentheses.md" >}})|Medium||||64.2%|
|1673|Find the Most Competitive Subsequence|[Go]({{< relref "/ChapterFour/1600~1699/1673.Find-the-Most-Competitive-Subsequence.md" >}})|Medium||||45.4%|
|1673|Find the Most Competitive Subsequence|[Go]({{< relref "/ChapterFour/1600~1699/1673.Find-the-Most-Competitive-Subsequence.md" >}})|Medium||||45.5%|
|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|

View File

@ -34,7 +34,7 @@ weight: 2
|0227|Basic Calculator II|[Go]({{< relref "/ChapterFour/0200~0299/0227.Basic-Calculator-II.md" >}})|Medium||||38.7%|
|0344|Reverse String|[Go]({{< relref "/ChapterFour/0300~0399/0344.Reverse-String.md" >}})|Easy| O(n)| O(1)||70.6%|
|0345|Reverse Vowels of a String|[Go]({{< relref "/ChapterFour/0300~0399/0345.Reverse-Vowels-of-a-String.md" >}})|Easy| O(n)| O(1)||45.1%|
|0385|Mini Parser|[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})|Medium||||34.5%|
|0385|Mini Parser|[Go]({{< relref "/ChapterFour/0300~0399/0385.Mini-Parser.md" >}})|Medium||||34.6%|
|0387|First Unique Character in a String|[Go]({{< relref "/ChapterFour/0300~0399/0387.First-Unique-Character-in-a-String.md" >}})|Easy||||53.8%|
|0537|Complex Number Multiplication|[Go]({{< relref "/ChapterFour/0500~0599/0537.Complex-Number-Multiplication.md" >}})|Medium||||68.4%|
|0541|Reverse String II|[Go]({{< relref "/ChapterFour/0500~0599/0541.Reverse-String-II.md" >}})|Easy||||49.4%|
@ -44,6 +44,7 @@ weight: 2
|0819|Most Common Word|[Go]({{< relref "/ChapterFour/0800~0899/0819.Most-Common-Word.md" >}})|Easy||||45.5%|
|0842|Split Array into Fibonacci Sequence|[Go]({{< relref "/ChapterFour/0800~0899/0842.Split-Array-into-Fibonacci-Sequence.md" >}})|Medium| O(n^2)| O(1)|❤️|37.0%|
|0856|Score of Parentheses|[Go]({{< relref "/ChapterFour/0800~0899/0856.Score-of-Parentheses.md" >}})|Medium| O(n)| O(n)||64.9%|
|0916|Word Subsets|[Go]({{< relref "/ChapterFour/0900~0999/0916.Word-Subsets.md" >}})|Medium||||51.1%|
|0925|Long Pressed Name|[Go]({{< relref "/ChapterFour/0900~0999/0925.Long-Pressed-Name.md" >}})|Easy| O(n)| O(1)||37.6%|
|0966|Vowel Spellchecker|[Go]({{< relref "/ChapterFour/0900~0999/0966.Vowel-Spellchecker.md" >}})|Medium||||51.9%|
|1003|Check If Word Is Valid After Substitutions|[Go]({{< relref "/ChapterFour/1000~1099/1003.Check-If-Word-Is-Valid-After-Substitutions.md" >}})|Medium| O(n)| O(1)||56.6%|
@ -63,7 +64,7 @@ weight: 2
|1662|Check If Two String Arrays are Equivalent|[Go]({{< relref "/ChapterFour/1600~1699/1662.Check-If-Two-String-Arrays-are-Equivalent.md" >}})|Easy||||82.6%|
|1668|Maximum Repeating Substring|[Go]({{< relref "/ChapterFour/1600~1699/1668.Maximum-Repeating-Substring.md" >}})|Easy||||38.7%|
|1678|Goal Parser Interpretation|[Go]({{< relref "/ChapterFour/1600~1699/1678.Goal-Parser-Interpretation.md" >}})|Easy||||85.3%|
|1684|Count the Number of Consistent Strings|[Go]({{< relref "/ChapterFour/1600~1699/1684.Count-the-Number-of-Consistent-Strings.md" >}})|Easy||||82.0%|
|1684|Count the Number of Consistent Strings|[Go]({{< relref "/ChapterFour/1600~1699/1684.Count-the-Number-of-Consistent-Strings.md" >}})|Easy||||82.1%|
|1694|Reformat Phone Number|[Go]({{< relref "/ChapterFour/1600~1699/1694.Reformat-Phone-Number.md" >}})|Easy||||65.5%|
|1704|Determine if String Halves Are Alike|[Go]({{< relref "/ChapterFour/1700~1799/1704.Determine-if-String-Halves-Are-Alike.md" >}})|Easy||||77.1%|
|1736|Latest Time by Replacing Hidden Digits|[Go]({{< relref "/ChapterFour/1700~1799/1736.Latest-Time-by-Replacing-Hidden-Digits.md" >}})|Easy||||41.2%|