From 3f3026ca0583ec468649ebe71472bc16c25af606 Mon Sep 17 00:00:00 2001 From: YDZ Date: Thu, 4 Mar 2021 03:34:47 +0800 Subject: [PATCH] Update solution 1178 --- README.md | 56 ++++---- ... Number of Valid Words for Each Puzzle.go} | 10 +- ...er of Valid Words for Each Puzzle_test.go} | 0 .../README.md | 116 +++++++++++++++++ .../1178.find-Num-Of-Valid-Words/README.md | 86 ------------ .../1100~1199/1175.Prime-Arrangements.md | 2 +- ...8.Number-of-Valid-Words-for-Each-Puzzle.md | 123 ++++++++++++++++++ .../1184.Distance-Between-Bus-Stops.md | 2 +- website/content/ChapterTwo/Array.md | 4 +- .../content/ChapterTwo/Bit_Manipulation.md | 3 +- website/content/ChapterTwo/Hash_Table.md | 3 +- website/content/ChapterTwo/Linked_List.md | 2 +- website/content/ChapterTwo/Math.md | 2 +- website/content/ChapterTwo/Two_Pointers.md | 2 +- 14 files changed, 280 insertions(+), 131 deletions(-) rename leetcode/{1178.find-Num-Of-Valid-Words/1178.go => 1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle.go} (91%) rename leetcode/{1178.find-Num-Of-Valid-Words/1178_test.go => 1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle_test.go} (100%) create mode 100644 leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/README.md delete mode 100644 leetcode/1178.find-Num-Of-Valid-Words/README.md create mode 100644 website/content/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md diff --git a/README.md b/README.md index 9f36138d..23cb7efb 100755 --- a/README.md +++ b/README.md @@ -126,15 +126,15 @@ | | Easy | Medium | Hard | Total | |:--------:|:--------:|:--------:|:--------:|:--------:| |Optimizing|36|43|15|94| -|Accepted|**271**|**338**|**101**|**710**| +|Accepted|**271**|**338**|**102**|**711**| |Total|464|936|377|1777| -|Perfection Rate|86.7%|87.3%|85.1%|86.8%| -|Completion Rate|58.4%|36.1%|26.8%|40.0%| +|Perfection Rate|86.7%|87.3%|85.3%|86.8%| +|Completion Rate|58.4%|36.1%|27.1%|40.0%| |------------|----------------------------|----------------------------|----------------------------|----------------------------| ## 二. 目录 -以下已经收录了 616 道题的题解,还有 12 道题在尝试优化到 beats 100% +以下已经收录了 617 道题的题解,还有 12 道题在尝试优化到 beats 100% | No. | Title | Solution | Acceptance | Difficulty | Frequency | |:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:| @@ -152,11 +152,11 @@ |0012|Integer to Roman||56.2%|Medium|| |0013|Roman to Integer|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0013.Roman-to-Integer)|56.9%|Easy|| |0014|Longest Common Prefix||36.1%|Easy|| -|0015|3Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0015.3Sum)|28.0%|Medium|| +|0015|3Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0015.3Sum)|28.1%|Medium|| |0016|3Sum Closest|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0016.3Sum-Closest)|46.3%|Medium|| |0017|Letter Combinations of a Phone Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0017.Letter-Combinations-of-a-Phone-Number)|49.2%|Medium|| |0018|4Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0018.4Sum)|34.9%|Medium|| -|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|| +|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.8%|Medium|| |0020|Valid Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0020.Valid-Parentheses)|39.9%|Easy|| |0021|Merge Two Sorted Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0021.Merge-Two-Sorted-Lists)|56.1%|Easy|| |0022|Generate Parentheses|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0022.Generate-Parentheses)|65.3%|Medium|| @@ -405,7 +405,7 @@ |0265|Paint House II||45.7%|Hard|| |0266|Palindrome Permutation||62.5%|Easy|| |0267|Palindrome Permutation II||37.4%|Medium|| -|0268|Missing Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0268.Missing-Number)|54.5%|Easy|| +|0268|Missing Number|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0268.Missing-Number)|54.6%|Easy|| |0269|Alien Dictionary||33.7%|Hard|| |0270|Closest Binary Search Tree Value||49.9%|Easy|| |0271|Encode and Decode Strings||32.8%|Medium|| @@ -544,7 +544,7 @@ |0404|Sum of Left Leaves|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0404.Sum-of-Left-Leaves)|52.3%|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.4%|Medium|| -|0407|Trapping Rain Water II||44.3%|Hard|| +|0407|Trapping Rain Water II||44.2%|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|| |0410|Split Array Largest Sum|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0410.Split-Array-Largest-Sum)|46.4%|Hard|| @@ -671,7 +671,7 @@ |0531|Lonely Pixel I||59.6%|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.3%|Medium|| |0533|Lonely Pixel II||48.1%|Medium|| -|0534|Game Play Analysis III||79.3%|Medium|| +|0534|Game Play Analysis III||79.4%|Medium|| |0535|Encode and Decode TinyURL||81.0%|Medium|| |0536|Construct Binary Tree from String||50.8%|Medium|| |0537|Complex Number Multiplication|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0537.Complex-Number-Multiplication)|68.3%|Medium|| @@ -715,7 +715,7 @@ |0575|Distribute Candies|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0575.Distribute-Candies)|64.6%|Easy|| |0576|Out of Boundary Paths||36.0%|Medium|| |0577|Employee Bonus||71.5%|Easy|| -|0578|Get Highest Answer Rate Question||41.7%|Medium|| +|0578|Get Highest Answer Rate Question||41.8%|Medium|| |0579|Find Cumulative Salary of an Employee||38.4%|Hard|| |0580|Count Student Number in Departments||51.8%|Medium|| |0581|Shortest Unsorted Continuous Subarray|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0581.Shortest-Unsorted-Continuous-Subarray)|32.8%|Medium|| @@ -755,7 +755,7 @@ |0615|Average Salary: Departments VS Company||52.6%|Hard|| |0616|Add Bold Tag in String||44.7%|Medium|| |0617|Merge Two Binary Trees||75.4%|Easy|| -|0618|Students Report By Geography||60.0%|Hard|| +|0618|Students Report By Geography||59.9%|Hard|| |0619|Biggest Single Number||44.9%|Easy|| |0620|Not Boring Movies||69.9%|Easy|| |0621|Task Scheduler||51.9%|Medium|| @@ -767,7 +767,7 @@ |0627|Swap Salary||77.7%|Easy|| |0628|Maximum Product of Three Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0628.Maximum-Product-of-Three-Numbers)|46.9%|Easy|| |0629|K Inverse Pairs Array||31.7%|Hard|| -|0630|Course Schedule III||33.7%|Hard|| +|0630|Course Schedule III||33.8%|Hard|| |0631|Design Excel Sum Formula||32.2%|Hard|| |0632|Smallest Range Covering Elements from K Lists|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0632.Smallest-Range-Covering-Elements-from-K-Lists)|54.2%|Hard|| |0633|Sum of Square Numbers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0633.Sum-of-Square-Numbers)|32.6%|Medium|| @@ -776,7 +776,7 @@ |0636|Exclusive Time of Functions|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0636.Exclusive-Time-of-Functions)|54.5%|Medium|| |0637|Average of Levels in Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0637.Average-of-Levels-in-Binary-Tree)|64.9%|Easy|| |0638|Shopping Offers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0638.Shopping-Offers)|52.9%|Medium|| -|0639|Decode Ways II||27.6%|Hard|| +|0639|Decode Ways II||27.5%|Hard|| |0640|Solve the Equation||42.7%|Medium|| |0641|Design Circular Deque||55.9%|Medium|| |0642|Design Search Autocomplete System||46.3%|Hard|| @@ -1152,7 +1152,7 @@ |1012|Numbers With Repeated Digits||37.8%|Hard|| |1013|Partition Array Into Three Parts With Equal Sum||48.8%|Easy|| |1014|Best Sightseeing Pair||52.9%|Medium|| -|1015|Smallest Integer Divisible by K||41.8%|Medium|| +|1015|Smallest Integer Divisible by K||41.9%|Medium|| |1016|Binary String With Substrings Representing 1 To N||58.9%|Medium|| |1017|Convert to Base -2|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1017.Convert-to-Base--2)|59.7%|Medium|| |1018|Binary Prefix Divisible By 5|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1018.Binary-Prefix-Divisible-By-5)|47.8%|Easy|| @@ -1311,11 +1311,11 @@ |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.5%|Medium|| |1172|Dinner Plate Stacks||37.8%|Hard|| |1173|Immediate Food Delivery I||82.4%|Easy|| -|1174|Immediate Food Delivery II||61.8%|Medium|| +|1174|Immediate Food Delivery II||61.9%|Medium|| |1175|Prime Arrangements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1175.Prime-Arrangements)|52.0%|Easy|| |1176|Diet Plan Performance||53.8%|Easy|| |1177|Can Make Palindrome from Substring||36.1%|Medium|| -|1178|Number of Valid Words for Each Puzzle||39.4%|Hard|| +|1178|Number of Valid Words for Each Puzzle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle)|39.4%|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|| @@ -1331,7 +1331,7 @@ |1191|K-Concatenation Maximum Sum||25.2%|Medium|| |1192|Critical Connections in a Network||50.1%|Hard|| |1193|Monthly Transactions I||69.2%|Medium|| -|1194|Tournament Winners||52.2%|Hard|| +|1194|Tournament Winners||52.3%|Hard|| |1195|Fizz Buzz Multithreaded||70.6%|Medium|| |1196|How Many Apples Can You Put into the Basket||68.1%|Easy|| |1197|Minimum Knight Moves||37.3%|Medium|| @@ -1421,7 +1421,7 @@ |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.3%|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.6%|Medium|| -|1284|Minimum Number of Flips to Convert Binary Matrix to Zero Matrix||70.1%|Hard|| +|1284|Minimum Number of Flips to Convert Binary Matrix to Zero Matrix||70.0%|Hard|| |1285|Find the Start and End Number of Continuous Ranges||87.3%|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.1%|Easy|| @@ -1452,7 +1452,7 @@ |1312|Minimum Insertion Steps to Make a String Palindrome||59.7%|Hard|| |1313|Decompress Run-Length Encoded List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1313.Decompress-Run-Length-Encoded-List)|85.4%|Easy|| |1314|Matrix Block Sum||73.6%|Medium|| -|1315|Sum of Nodes with Even-Valued Grandparent||84.3%|Medium|| +|1315|Sum of Nodes with Even-Valued Grandparent||84.2%|Medium|| |1316|Distinct Echo Substrings||49.7%|Hard|| |1317|Convert Integer to the Sum of Two No-Zero Integers|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1317.Convert-Integer-to-the-Sum-of-Two-No-Zero-Integers)|56.8%|Easy|| |1318|Minimum Flips to Make a OR b Equal to c||64.0%|Medium|| @@ -1520,7 +1520,7 @@ |1380|Lucky Numbers in a Matrix|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1380.Lucky-Numbers-in-a-Matrix)|70.6%|Easy|| |1381|Design a Stack With Increment Operation||76.2%|Medium|| |1382|Balance a Binary Search Tree||76.3%|Medium|| -|1383|Maximum Performance of a Team||35.8%|Hard|| +|1383|Maximum Performance of a Team||35.7%|Hard|| |1384|Total Sales Amount by Year||64.7%|Hard|| |1385|Find the Distance Value Between Two Arrays|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1385.Find-the-Distance-Value-Between-Two-Arrays)|66.3%|Easy|| |1386|Cinema Seat Allocation||35.7%|Medium|| @@ -1528,7 +1528,7 @@ |1388|Pizza With 3n Slices||45.7%|Hard|| |1389|Create Target Array in the Given Order|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1389.Create-Target-Array-in-the-Given-Order)|84.7%|Easy|| |1390|Four Divisors||39.2%|Medium|| -|1391|Check if There is a Valid Path in a Grid||44.9%|Medium|| +|1391|Check if There is a Valid Path in a Grid||45.0%|Medium|| |1392|Longest Happy Prefix||41.9%|Hard|| |1393|Capital Gain/Loss||90.8%|Medium|| |1394|Find Lucky Integer in an Array||63.2%|Easy|| @@ -1664,7 +1664,7 @@ |1524|Number of Sub-arrays With Odd Sum||40.0%|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||66.7%|Easy|| +|1527|Patients With a Condition||66.6%|Easy|| |1528|Shuffle String||85.6%|Easy|| |1529|Bulb Switcher IV||70.9%|Medium|| |1530|Number of Good Leaf Nodes Pairs||56.1%|Medium|| @@ -1755,7 +1755,7 @@ |1615|Maximal Network Rank||52.2%|Medium|| |1616|Split Two Strings to Make Palindrome||36.2%|Medium|| |1617|Count Subtrees With Max Distance Between Cities||63.3%|Hard|| -|1618|Maximum Font to Fit a Sentence in a Screen||56.6%|Medium|| +|1618|Maximum Font to Fit a Sentence in a Screen||56.7%|Medium|| |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)|64.9%|Easy|| |1620|Coordinate With Maximum Network Quality||37.1%|Medium|| |1621|Number of Sets of K Non-Overlapping Line Segments||41.2%|Medium|| @@ -1885,15 +1885,15 @@ |1745|Palindrome Partitioning IV||49.2%|Hard|| |1746|Maximum Subarray Sum After One Operation||63.5%|Medium|| |1747|Leetflex Banned Accounts||69.7%|Medium|| -|1748|Sum of Unique Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1748.Sum-of-Unique-Elements)|76.0%|Easy|| +|1748|Sum of Unique Elements|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1748.Sum-of-Unique-Elements)|75.9%|Easy|| |1749|Maximum Absolute Sum of Any Subarray||51.4%|Medium|| -|1750|Minimum Length of String After Deleting Similar Ends||42.4%|Medium|| +|1750|Minimum Length of String After Deleting Similar Ends||42.5%|Medium|| |1751|Maximum Number of Events That Can Be Attended II||47.4%|Hard|| |1752|Check if Array Is Sorted and Rotated|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1752.Check-if-Array-Is-Sorted-and-Rotated)|64.2%|Easy|| |1753|Maximum Score From Removing Stones||61.2%|Medium|| |1754|Largest Merge Of Two Strings||39.8%|Medium|| |1755|Closest Subsequence Sum||35.9%|Hard|| -|1756|Design Most Recently Used Queue||77.3%|Medium|| +|1756|Design Most Recently Used Queue||77.4%|Medium|| |1757|Recyclable and Low Fat Products||96.3%|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)|59.3%|Easy|| |1759|Count Number of Homogenous Substrings||41.7%|Medium|| @@ -1913,8 +1913,8 @@ |1773|Count Items Matching a Rule||87.7%|Easy|| |1774|Closest Dessert Cost||51.2%|Medium|| |1775|Equal Sum Arrays With Minimum Number of Operations||50.3%|Medium|| -|1776|Car Fleet II||41.3%|Hard|| -|1777|Product's Price for Each Store||86.1%|Easy|| +|1776|Car Fleet II||41.4%|Hard|| +|1777|Product's Price for Each Store||86.2%|Easy|| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------| ------------------------------------------------------------------ diff --git a/leetcode/1178.find-Num-Of-Valid-Words/1178.go b/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle.go similarity index 91% rename from leetcode/1178.find-Num-Of-Valid-Words/1178.go rename to leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle.go index f7f2e064..dca6fd62 100644 --- a/leetcode/1178.find-Num-Of-Valid-Words/1178.go +++ b/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle.go @@ -4,15 +4,13 @@ package leetcode 匹配跟单词中的字母顺序,字母个数都无关,可以用bitmap压缩 1. 记录word中 利用map记录各种bit标示的个数 2. puzzles 中各个字母都不相同! 记录bitmap,然后搜索子空间中各种bit标识的个数的和 - 因为puzzles长度最长是7,所以搜索空间 2^7 + 因为puzzles长度最长是7,所以搜索空间 2^7 */ func findNumOfValidWords(words []string, puzzles []string) []int { - - wordBitStatusMap := make(map[uint32]int, 0) + wordBitStatusMap, res := make(map[uint32]int, 0), []int{} for _, w := range words { wordBitStatusMap[toBitMap([]byte(w))]++ } - var res []int for _, p := range puzzles { var bitMap uint32 var totalNum int @@ -20,7 +18,6 @@ func findNumOfValidWords(words []string, puzzles []string) []int { findNum([]byte(p)[1:], bitMap, &totalNum, wordBitStatusMap) res = append(res, totalNum) } - return res } @@ -38,14 +35,11 @@ func findNum(puzzles []byte, bitMap uint32, totalNum *int, m map[uint32]int) { *totalNum = *totalNum + m[bitMap] return } - //不包含puzzles[0],即puzzles[0]对应bit是0 findNum(puzzles[1:], bitMap, totalNum, m) - //包含puzzles[0],即puzzles[0]对应bit是1 bitMap |= (1 << (puzzles[0] - 'a')) findNum(puzzles[1:], bitMap, totalNum, m) bitMap ^= (1 << (puzzles[0] - 'a')) //异或 清零 - return } diff --git a/leetcode/1178.find-Num-Of-Valid-Words/1178_test.go b/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle_test.go similarity index 100% rename from leetcode/1178.find-Num-Of-Valid-Words/1178_test.go rename to leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/1178. Number of Valid Words for Each Puzzle_test.go diff --git a/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/README.md b/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/README.md new file mode 100644 index 00000000..d0442fe2 --- /dev/null +++ b/leetcode/1178.Number-of-Valid-Words-for-Each-Puzzle/README.md @@ -0,0 +1,116 @@ +# [1178. Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/) + + +## 题目 + +With respect to a given `puzzle` string, a `word` is *valid* if both the following conditions are satisfied: + +- `word` contains the first letter of `puzzle`. +- For each letter in `word`, that letter is in `puzzle`.For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid words are "beefed" (doesn't include "a") and "based" (includes "s" which isn't in the puzzle). + +Return an array `answer`, where `answer[i]` is the number of words in the given word list `words` that are valid with respect to the puzzle `puzzles[i]`. + +**Example :** + +``` +Input: +words = ["aaaa","asas","able","ability","actt","actor","access"], +puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"] +Output: [1,1,3,2,4,0] +Explanation: +1 valid word for "aboveyz" : "aaaa" +1 valid word for "abrodyz" : "aaaa" +3 valid words for "abslute" : "aaaa", "asas", "able" +2 valid words for "absoryz" : "aaaa", "asas" +4 valid words for "actresz" : "aaaa", "asas", "actt", "access" +There're no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'. + +``` + +**Constraints:** + +- `1 <= words.length <= 10^5` +- `4 <= words[i].length <= 50` +- `1 <= puzzles.length <= 10^4` +- `puzzles[i].length == 7` +- `words[i][j]`, `puzzles[i][j]` are English lowercase letters. +- Each `puzzles[i]` doesn't contain repeated characters. + +## 题目大意 + +外国友人仿照中国字谜设计了一个英文版猜字谜小游戏,请你来猜猜看吧。 + +字谜的迷面 puzzle 按字符串形式给出,如果一个单词 word 符合下面两个条件,那么它就可以算作谜底: + +- 单词 word 中包含谜面 puzzle 的第一个字母。 +- 单词 word 中的每一个字母都可以在谜面 puzzle 中找到。 +例如,如果字谜的谜面是 "abcdefg",那么可以作为谜底的单词有 "faced", "cabbage", 和 "baggage";而 "beefed"(不含字母 "a")以及 "based"(其中的 "s" 没有出现在谜面中)都不能作为谜底。 + +返回一个答案数组 answer,数组中的每个元素 answer[i] 是在给出的单词列表 words 中可以作为字谜迷面 puzzles[i] 所对应的谜底的单词数目。 + +提示: + +- 1 <= words.length <= 10^5 +- 4 <= words[i].length <= 50 +- 1 <= puzzles.length <= 10^4 +- puzzles[i].length == 7 +- words[i][j], puzzles[i][j] 都是小写英文字母。 +- 每个 puzzles[i] 所包含的字符都不重复。 + +## 解题思路 + +- 首先题目中两个限制条件非常关键:**puzzles[i].length == 7**,**每个 puzzles[i] 所包含的字符都不重复**。也就是说穷举每个puzzle的子串的搜索空间就是2^7=128,而且不用考虑去重问题。 +- 因为谜底的判断只跟字符是否出现有关,跟字符的个数无关,另外都是小写的英文字母,所以可以用 `bitmap` 来表示单词(word)。 +- 利用 `map` 记录不同状态的单词(word)的个数。 +- 根据题意,如果某个单词(word)是某个字谜(puzzle)的谜底,那么 `word` 的 `bitmap` 肯定对应于 `puzzle` 某个子串的 `bitmap` 表示,且 `bitmap` 中包含 `puzzle` 的第一个字母的 `bit` 占用。 +- 问题就转换为:求每一个 `puzzle` 的每一个子串,然后求和这个子串具有相同 `bitmap` 表示且 `word` 中包含 `puzzle` 的第一个字母的 `word` 的个数。 + +## 代码 + +```go +package leetcode + +/* + 匹配跟单词中的字母顺序,字母个数都无关,可以用bitmap压缩 + 1. 记录word中 利用map记录各种bit标示的个数 + 2. puzzles 中各个字母都不相同! 记录bitmap,然后搜索子空间中各种bit标识的个数的和 + 因为puzzles长度最长是7,所以搜索空间 2^7 +*/ +func findNumOfValidWords(words []string, puzzles []string) []int { + wordBitStatusMap, res := make(map[uint32]int, 0), []int{} + for _, w := range words { + wordBitStatusMap[toBitMap([]byte(w))]++ + } + for _, p := range puzzles { + var bitMap uint32 + var totalNum int + bitMap |= (1 << (p[0] - 'a')) //work中要包含 p 的第一个字母 所以这个bit位上必须是1 + findNum([]byte(p)[1:], bitMap, &totalNum, wordBitStatusMap) + res = append(res, totalNum) + } + return res +} + +func toBitMap(word []byte) uint32 { + var res uint32 + for _, b := range word { + res |= (1 << (b - 'a')) + } + return res +} + +//利用dfs 搜索 pussles的子空间 +func findNum(puzzles []byte, bitMap uint32, totalNum *int, m map[uint32]int) { + if len(puzzles) == 0 { + *totalNum = *totalNum + m[bitMap] + return + } + //不包含puzzles[0],即puzzles[0]对应bit是0 + findNum(puzzles[1:], bitMap, totalNum, m) + //包含puzzles[0],即puzzles[0]对应bit是1 + bitMap |= (1 << (puzzles[0] - 'a')) + findNum(puzzles[1:], bitMap, totalNum, m) + bitMap ^= (1 << (puzzles[0] - 'a')) //异或 清零 + return +} +``` \ No newline at end of file diff --git a/leetcode/1178.find-Num-Of-Valid-Words/README.md b/leetcode/1178.find-Num-Of-Valid-Words/README.md deleted file mode 100644 index 15bd9855..00000000 --- a/leetcode/1178.find-Num-Of-Valid-Words/README.md +++ /dev/null @@ -1,86 +0,0 @@ - - -# [1178. Number of Valid Words for Each Puzzle](https://leetcode-cn.com/problems/number-of-valid-words-for-each-puzzle/) - - -## 题目 - -With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: -word contains the first letter of puzzle. -For each letter in word, that letter is in puzzle. -For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid words are "beefed" (doesn't include "a") and "based" (includes "s" which isn't in the puzzle). -Return an array answer, where answer[i] is the number of words in the given word list words that are valid with respect to the puzzle puzzles[i]. - -**Example :** - -Input: -words = ["aaaa","asas","able","ability","actt","actor","access"], -puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"] -Output: [1,1,3,2,4,0] -Explanation: -1 valid word for "aboveyz" : "aaaa" -1 valid word for "abrodyz" : "aaaa" -3 valid words for "abslute" : "aaaa", "asas", "able" -2 valid words for "absoryz" : "aaaa", "asas" -4 valid words for "actresz" : "aaaa", "asas", "actt", "access" -There're no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'. - -**Constraints**: - -1 <= words.length <= 10^5 -4 <= words[i].length <= 50 -1 <= puzzles.length <= 10^4 -puzzles[i].length == 7 -words[i][j], puzzles[i][j] are English lowercase letters. -Each puzzles[i] doesn't contain repeated characters. - - -## 题目大意 - -外国友人仿照中国字谜设计了一个英文版猜字谜小游戏,请你来猜猜看吧。 - -字谜的迷面 puzzle 按字符串形式给出,如果一个单词 word 符合下面两个条件,那么它就可以算作谜底: - -单词 word 中包含谜面 puzzle 的第一个字母。 -单词 word 中的每一个字母都可以在谜面 puzzle 中找到。 -例如,如果字谜的谜面是 "abcdefg",那么可以作为谜底的单词有 "faced", "cabbage", 和 "baggage";而 "beefed"(不含字母 "a")以及 "based"(其中的 "s" 没有出现在谜面中)都不能作为谜底。 -返回一个答案数组 answer,数组中的每个元素 answer[i] 是在给出的单词列表 words 中可以作为字谜迷面 puzzles[i] 所对应的谜底的单词数目。 - - - -**示例:** - -输入: -words = ["aaaa","asas","able","ability","actt","actor","access"], -puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"] -输出:[1,1,3,2,4,0] -**解释:** -1 个单词可以作为 "aboveyz" 的谜底 : "aaaa" -1 个单词可以作为 "abrodyz" 的谜底 : "aaaa" -3 个单词可以作为 "abslute" 的谜底 : "aaaa", "asas", "able" -2 个单词可以作为 "absoryz" 的谜底 : "aaaa", "asas" -4 个单词可以作为 "actresz" 的谜底 : "aaaa", "asas", "actt", "access" -没有单词可以作为 "gaswxyz" 的谜底,因为列表中的单词都不含字母 'g'。 - -**提示:** - -1 <= words.length <= 10^5 -4 <= words[i].length <= 50 -1 <= puzzles.length <= 10^4 -puzzles[i].length == 7 -words[i][j], puzzles[i][j] 都是小写英文字母。 -每个 puzzles[i] 所包含的字符都不重复。 - -## 解题思路 - -首先题目中两个限制条件非常关键: - -- puzzles[i].length == 7 -- 每个 puzzles[i] 所包含的字符都不重复 - -也就是说穷举每个puzzle的子串的搜索空间就是2^7=128,而且不用考虑去重问题。 - -1. 因为谜底的判断只跟字符是否出现有关,跟字符的个数无关,另外都是小写的英文字母,所以可以用`bitmap`来表示单词(word)。 -2. 利用`map`记录不同状态的单词(word)的个数。 -3. 根据题意,如果某个单词(word)是某个字谜(puzzle)的谜底,那么word的bitmap肯定对应于puzzle某个子串的bitmap表示,且bitmap中包含puzzle的第一个字母的bit占用。 -4. 问题就转换为:求每一个puzzle的每一个子串,然后求和这个子串具有相同bitmap表示且word中包含puzzle的第一个字母的word的个数。 \ No newline at end of file diff --git a/website/content/ChapterFour/1100~1199/1175.Prime-Arrangements.md b/website/content/ChapterFour/1100~1199/1175.Prime-Arrangements.md index e6ef7db5..a147da04 100755 --- a/website/content/ChapterFour/1100~1199/1175.Prime-Arrangements.md +++ b/website/content/ChapterFour/1100~1199/1175.Prime-Arrangements.md @@ -68,5 +68,5 @@ func factorial(n int) int { ----------------------------------------------

⬅️上一页

-

下一页➡️

+

下一页➡️

diff --git a/website/content/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md b/website/content/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md new file mode 100644 index 00000000..0e065a56 --- /dev/null +++ b/website/content/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md @@ -0,0 +1,123 @@ +# [1178. Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/) + + +## 题目 + +With respect to a given `puzzle` string, a `word` is *valid* if both the following conditions are satisfied: + +- `word` contains the first letter of `puzzle`. +- For each letter in `word`, that letter is in `puzzle`.For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid words are "beefed" (doesn't include "a") and "based" (includes "s" which isn't in the puzzle). + +Return an array `answer`, where `answer[i]` is the number of words in the given word list `words` that are valid with respect to the puzzle `puzzles[i]`. + +**Example :** + +``` +Input: +words = ["aaaa","asas","able","ability","actt","actor","access"], +puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"] +Output: [1,1,3,2,4,0] +Explanation: +1 valid word for "aboveyz" : "aaaa" +1 valid word for "abrodyz" : "aaaa" +3 valid words for "abslute" : "aaaa", "asas", "able" +2 valid words for "absoryz" : "aaaa", "asas" +4 valid words for "actresz" : "aaaa", "asas", "actt", "access" +There're no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'. + +``` + +**Constraints:** + +- `1 <= words.length <= 10^5` +- `4 <= words[i].length <= 50` +- `1 <= puzzles.length <= 10^4` +- `puzzles[i].length == 7` +- `words[i][j]`, `puzzles[i][j]` are English lowercase letters. +- Each `puzzles[i]` doesn't contain repeated characters. + +## 题目大意 + +外国友人仿照中国字谜设计了一个英文版猜字谜小游戏,请你来猜猜看吧。 + +字谜的迷面 puzzle 按字符串形式给出,如果一个单词 word 符合下面两个条件,那么它就可以算作谜底: + +- 单词 word 中包含谜面 puzzle 的第一个字母。 +- 单词 word 中的每一个字母都可以在谜面 puzzle 中找到。 +例如,如果字谜的谜面是 "abcdefg",那么可以作为谜底的单词有 "faced", "cabbage", 和 "baggage";而 "beefed"(不含字母 "a")以及 "based"(其中的 "s" 没有出现在谜面中)都不能作为谜底。 + +返回一个答案数组 answer,数组中的每个元素 answer[i] 是在给出的单词列表 words 中可以作为字谜迷面 puzzles[i] 所对应的谜底的单词数目。 + +提示: + +- 1 <= words.length <= 10^5 +- 4 <= words[i].length <= 50 +- 1 <= puzzles.length <= 10^4 +- puzzles[i].length == 7 +- words[i][j], puzzles[i][j] 都是小写英文字母。 +- 每个 puzzles[i] 所包含的字符都不重复。 + +## 解题思路 + +- 首先题目中两个限制条件非常关键:**puzzles[i].length == 7**,**每个 puzzles[i] 所包含的字符都不重复**。也就是说穷举每个puzzle的子串的搜索空间就是2^7=128,而且不用考虑去重问题。 +- 因为谜底的判断只跟字符是否出现有关,跟字符的个数无关,另外都是小写的英文字母,所以可以用 `bitmap` 来表示单词(word)。 +- 利用 `map` 记录不同状态的单词(word)的个数。 +- 根据题意,如果某个单词(word)是某个字谜(puzzle)的谜底,那么 `word` 的 `bitmap` 肯定对应于 `puzzle` 某个子串的 `bitmap` 表示,且 `bitmap` 中包含 `puzzle` 的第一个字母的 `bit` 占用。 +- 问题就转换为:求每一个 `puzzle` 的每一个子串,然后求和这个子串具有相同 `bitmap` 表示且 `word` 中包含 `puzzle` 的第一个字母的 `word` 的个数。 + +## 代码 + +```go +package leetcode + +/* + 匹配跟单词中的字母顺序,字母个数都无关,可以用bitmap压缩 + 1. 记录word中 利用map记录各种bit标示的个数 + 2. puzzles 中各个字母都不相同! 记录bitmap,然后搜索子空间中各种bit标识的个数的和 + 因为puzzles长度最长是7,所以搜索空间 2^7 +*/ +func findNumOfValidWords(words []string, puzzles []string) []int { + wordBitStatusMap, res := make(map[uint32]int, 0), []int{} + for _, w := range words { + wordBitStatusMap[toBitMap([]byte(w))]++ + } + for _, p := range puzzles { + var bitMap uint32 + var totalNum int + bitMap |= (1 << (p[0] - 'a')) //work中要包含 p 的第一个字母 所以这个bit位上必须是1 + findNum([]byte(p)[1:], bitMap, &totalNum, wordBitStatusMap) + res = append(res, totalNum) + } + return res +} + +func toBitMap(word []byte) uint32 { + var res uint32 + for _, b := range word { + res |= (1 << (b - 'a')) + } + return res +} + +//利用dfs 搜索 pussles的子空间 +func findNum(puzzles []byte, bitMap uint32, totalNum *int, m map[uint32]int) { + if len(puzzles) == 0 { + *totalNum = *totalNum + m[bitMap] + return + } + //不包含puzzles[0],即puzzles[0]对应bit是0 + findNum(puzzles[1:], bitMap, totalNum, m) + //包含puzzles[0],即puzzles[0]对应bit是1 + bitMap |= (1 << (puzzles[0] - 'a')) + findNum(puzzles[1:], bitMap, totalNum, m) + bitMap ^= (1 << (puzzles[0] - 'a')) //异或 清零 + return +} +``` + + +---------------------------------------------- +
+

⬅️上一页

+

下一页➡️

+
diff --git a/website/content/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md b/website/content/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md index 7d3f9829..6dbf09a2 100755 --- a/website/content/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md +++ b/website/content/ChapterFour/1100~1199/1184.Distance-Between-Bus-Stops.md @@ -84,6 +84,6 @@ func distanceBetweenBusStops(distance []int, start int, destination int) int { ----------------------------------------------
-

⬅️上一页

+

⬅️上一页

下一页➡️

diff --git a/website/content/ChapterTwo/Array.md b/website/content/ChapterTwo/Array.md index 926edb63..dcdf7cb1 100644 --- a/website/content/ChapterTwo/Array.md +++ b/website/content/ChapterTwo/Array.md @@ -66,7 +66,7 @@ weight: 1 |0219|Contains Duplicate II|[Go]({{< relref "/ChapterFour/0200~0299/0219.Contains-Duplicate-II.md" >}})|Easy| O(n)| O(n)||38.6%| |0228|Summary Ranges|[Go]({{< relref "/ChapterFour/0200~0299/0228.Summary-Ranges.md" >}})|Easy||||42.4%| |0229|Majority Element II|[Go]({{< relref "/ChapterFour/0200~0299/0229.Majority-Element-II.md" >}})|Medium||||38.8%| -|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||54.5%| +|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||54.6%| |0283|Move Zeroes|[Go]({{< relref "/ChapterFour/0200~0299/0283.Move-Zeroes.md" >}})|Easy| O(n)| O(1)||58.6%| |0287|Find the Duplicate Number|[Go]({{< relref "/ChapterFour/0200~0299/0287.Find-the-Duplicate-Number.md" >}})|Medium| O(n)| O(1)|❤️|57.6%| |0414|Third Maximum Number|[Go]({{< relref "/ChapterFour/0400~0499/0414.Third-Maximum-Number.md" >}})|Easy||||30.7%| @@ -166,7 +166,7 @@ weight: 1 |1700|Number of Students Unable to Eat Lunch|[Go]({{< relref "/ChapterFour/1700~1799/1700.Number-of-Students-Unable-to-Eat-Lunch.md" >}})|Easy||||68.4%| |1732|Find the Highest Altitude|[Go]({{< relref "/ChapterFour/1700~1799/1732.Find-the-Highest-Altitude.md" >}})|Easy||||80.9%| |1742|Maximum Number of Balls in a Box|[Go]({{< relref "/ChapterFour/1700~1799/1742.Maximum-Number-of-Balls-in-a-Box.md" >}})|Easy||||74.9%| -|1748|Sum of Unique Elements|[Go]({{< relref "/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md" >}})|Easy||||76.0%| +|1748|Sum of Unique Elements|[Go]({{< relref "/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md" >}})|Easy||||75.9%| |1752|Check if Array Is Sorted and Rotated|[Go]({{< relref "/ChapterFour/1700~1799/1752.Check-if-Array-Is-Sorted-and-Rotated.md" >}})|Easy||||64.2%| |1758|Minimum Changes To Make Alternating Binary String|[Go]({{< relref "/ChapterFour/1700~1799/1758.Minimum-Changes-To-Make-Alternating-Binary-String.md" >}})|Easy||||59.3%| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------| diff --git a/website/content/ChapterTwo/Bit_Manipulation.md b/website/content/ChapterTwo/Bit_Manipulation.md index 23071a8f..e87f7148 100644 --- a/website/content/ChapterTwo/Bit_Manipulation.md +++ b/website/content/ChapterTwo/Bit_Manipulation.md @@ -54,7 +54,7 @@ X & ~X = 0 |0201|Bitwise AND of Numbers Range|[Go]({{< relref "/ChapterFour/0200~0299/0201.Bitwise-AND-of-Numbers-Range.md" >}})|Medium| O(n)| O(1)|❤️|39.6%| |0231|Power of Two|[Go]({{< relref "/ChapterFour/0200~0299/0231.Power-of-Two.md" >}})|Easy| O(1)| O(1)||43.8%| |0260|Single Number III|[Go]({{< relref "/ChapterFour/0200~0299/0260.Single-Number-III.md" >}})|Medium| O(n)| O(1)|❤️|65.3%| -|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy| O(n)| O(1)||54.5%| +|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy| O(n)| O(1)||54.6%| |0318|Maximum Product of Word Lengths|[Go]({{< relref "/ChapterFour/0300~0399/0318.Maximum-Product-of-Word-Lengths.md" >}})|Medium| O(n)| O(1)||52.3%| |0338|Counting Bits|[Go]({{< relref "/ChapterFour/0300~0399/0338.Counting-Bits.md" >}})|Medium| O(n)| O(n)||70.4%| |0342|Power of Four|[Go]({{< relref "/ChapterFour/0300~0399/0342.Power-of-Four.md" >}})|Easy| O(n)| O(1)||41.7%| @@ -73,6 +73,7 @@ X & ~X = 0 |0762|Prime Number of Set Bits in Binary Representation|[Go]({{< relref "/ChapterFour/0700~0799/0762.Prime-Number-of-Set-Bits-in-Binary-Representation.md" >}})|Easy| O(n)| O(1)||64.4%| |0784|Letter Case Permutation|[Go]({{< relref "/ChapterFour/0700~0799/0784.Letter-Case-Permutation.md" >}})|Medium| O(n)| O(1)||68.5%| |0898|Bitwise ORs of Subarrays|[Go]({{< relref "/ChapterFour/0800~0899/0898.Bitwise-ORs-of-Subarrays.md" >}})|Medium| O(n)| O(1)||34.2%| +|1178|Number of Valid Words for Each Puzzle|[Go]({{< relref "/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md" >}})|Hard||||39.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%| |1720|Decode XORed Array|[Go]({{< relref "/ChapterFour/1700~1799/1720.Decode-XORed-Array.md" >}})|Easy||||85.3%| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------| diff --git a/website/content/ChapterTwo/Hash_Table.md b/website/content/ChapterTwo/Hash_Table.md index 2fa63cef..432d03de 100644 --- a/website/content/ChapterTwo/Hash_Table.md +++ b/website/content/ChapterTwo/Hash_Table.md @@ -72,13 +72,14 @@ weight: 13 |1002|Find Common Characters|[Go]({{< relref "/ChapterFour/1000~1099/1002.Find-Common-Characters.md" >}})|Easy||||68.6%| |1078|Occurrences After Bigram|[Go]({{< relref "/ChapterFour/1000~1099/1078.Occurrences-After-Bigram.md" >}})|Easy||||64.9%| |1160|Find Words That Can Be Formed by Characters|[Go]({{< relref "/ChapterFour/1100~1199/1160.Find-Words-That-Can-Be-Formed-by-Characters.md" >}})|Easy||||67.9%| +|1178|Number of Valid Words for Each Puzzle|[Go]({{< relref "/ChapterFour/1100~1199/1178.Number-of-Valid-Words-for-Each-Puzzle.md" >}})|Hard||||39.4%| |1189|Maximum Number of Balloons|[Go]({{< relref "/ChapterFour/1100~1199/1189.Maximum-Number-of-Balloons.md" >}})|Easy||||61.8%| |1207|Unique Number of Occurrences|[Go]({{< relref "/ChapterFour/1200~1299/1207.Unique-Number-of-Occurrences.md" >}})|Easy||||71.8%| |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.0%| |1640|Check Array Formation Through Concatenation|[Go]({{< relref "/ChapterFour/1600~1699/1640.Check-Array-Formation-Through-Concatenation.md" >}})|Easy||||60.0%| |1679|Max Number of K-Sum Pairs|[Go]({{< relref "/ChapterFour/1600~1699/1679.Max-Number-of-K-Sum-Pairs.md" >}})|Medium||||54.1%| -|1748|Sum of Unique Elements|[Go]({{< relref "/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md" >}})|Easy||||76.0%| +|1748|Sum of Unique Elements|[Go]({{< relref "/ChapterFour/1700~1799/1748.Sum-of-Unique-Elements.md" >}})|Easy||||75.9%| |------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------| diff --git a/website/content/ChapterTwo/Linked_List.md b/website/content/ChapterTwo/Linked_List.md index 721f9887..b6f7df1f 100644 --- a/website/content/ChapterTwo/Linked_List.md +++ b/website/content/ChapterTwo/Linked_List.md @@ -24,7 +24,7 @@ weight: 4 | No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance | |:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: | |0002|Add Two Numbers|[Go]({{< relref "/ChapterFour/0001~0099/0002.Add-Two-Numbers.md" >}})|Medium| O(n)| O(1)||35.5%| -|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.8%| +|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)||56.1%| |0023|Merge k Sorted Lists|[Go]({{< relref "/ChapterFour/0001~0099/0023.Merge-k-Sorted-Lists.md" >}})|Hard| O(log n)| O(1)|❤️|42.7%| |0024|Swap Nodes in Pairs|[Go]({{< relref "/ChapterFour/0001~0099/0024.Swap-Nodes-in-Pairs.md" >}})|Medium| O(n)| O(1)||53.1%| diff --git a/website/content/ChapterTwo/Math.md b/website/content/ChapterTwo/Math.md index e1de48eb..03b5d1c3 100644 --- a/website/content/ChapterTwo/Math.md +++ b/website/content/ChapterTwo/Math.md @@ -28,7 +28,7 @@ weight: 12 |0231|Power of Two|[Go]({{< relref "/ChapterFour/0200~0299/0231.Power-of-Two.md" >}})|Easy| O(1)| O(1)||43.8%| |0258|Add Digits|[Go]({{< relref "/ChapterFour/0200~0299/0258.Add-Digits.md" >}})|Easy||||58.5%| |0263|Ugly Number|[Go]({{< relref "/ChapterFour/0200~0299/0263.Ugly-Number.md" >}})|Easy| O(log n)| O(1)||41.7%| -|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||54.5%| +|0268|Missing Number|[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})|Easy||||54.6%| |0326|Power of Three|[Go]({{< relref "/ChapterFour/0300~0399/0326.Power-of-Three.md" >}})|Easy| O(1)| O(1)||42.1%| |0343|Integer Break|[Go]({{< relref "/ChapterFour/0300~0399/0343.Integer-Break.md" >}})|Medium| O(n^2)| O(n)||51.2%| |0357|Count Numbers with Unique Digits|[Go]({{< relref "/ChapterFour/0300~0399/0357.Count-Numbers-with-Unique-Digits.md" >}})|Medium| O(1)| O(1)||48.9%| diff --git a/website/content/ChapterTwo/Two_Pointers.md b/website/content/ChapterTwo/Two_Pointers.md index eccd3205..e9448f96 100644 --- a/website/content/ChapterTwo/Two_Pointers.md +++ b/website/content/ChapterTwo/Two_Pointers.md @@ -37,7 +37,7 @@ weight: 3 |0015|3Sum|[Go]({{< relref "/ChapterFour/0001~0099/0015.3Sum.md" >}})|Medium| O(n^2)| O(n)|❤️|28.0%| |0016|3Sum Closest|[Go]({{< relref "/ChapterFour/0001~0099/0016.3Sum-Closest.md" >}})|Medium| O(n^2)| O(1)|❤️|46.3%| |0018|4Sum|[Go]({{< relref "/ChapterFour/0001~0099/0018.4Sum.md" >}})|Medium| O(n^3)| O(n^2)|❤️|34.9%| -|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.8%| +|0019|Remove Nth Node From End of List|[Go]({{< relref "/ChapterFour/0001~0099/0019.Remove-Nth-Node-From-End-of-List.md" >}})|Medium| O(n)| O(1)||35.7%| |0026|Remove Duplicates from Sorted Array|[Go]({{< relref "/ChapterFour/0001~0099/0026.Remove-Duplicates-from-Sorted-Array.md" >}})|Easy| O(n)| O(1)||46.6%| |0027|Remove Element|[Go]({{< relref "/ChapterFour/0001~0099/0027.Remove-Element.md" >}})|Easy| O(n)| O(1)||49.3%| |0028|Implement strStr()|[Go]({{< relref "/ChapterFour/0001~0099/0028.Implement-strStr.md" >}})|Easy| O(n)| O(1)||35.2%|