Back to Leetcode Go

2.14 ✅ Sorting

website/content/ChapterTwo/Sorting.md

1.7.115.3 KB
Original Source

Sorting

  • 深刻的理解多路快排。第 75 题。
  • 链表的排序,插入排序(第 147 题)和归并排序(第 148 题)
  • 桶排序和基数排序。第 164 题。
  • "摆动排序"。第 324 题。
  • 两两不相邻的排序。第 767 题,第 1054 题。
  • "饼子排序"。第 969 题。
No.TitleSolutionDifficultyTimeComplexitySpaceComplexityFavoriteAcceptance
00153Sum[Go]({{< relref "/ChapterFour/0001~0099/0015.3Sum.md" >}})Medium32.6%
00163Sum Closest[Go]({{< relref "/ChapterFour/0001~0099/0016.3Sum-Closest.md" >}})Medium45.8%
00184Sum[Go]({{< relref "/ChapterFour/0001~0099/0018.4Sum.md" >}})Medium35.9%
0049Group Anagrams[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})Medium66.7%
0056Merge Intervals[Go]({{< relref "/ChapterFour/0001~0099/0056.Merge-Intervals.md" >}})MediumO(n log n)O(log n)46.2%
0075Sort Colors[Go]({{< relref "/ChapterFour/0001~0099/0075.Sort-Colors.md" >}})MediumO(n)O(1)❤️58.5%
0088Merge Sorted Array[Go]({{< relref "/ChapterFour/0001~0099/0088.Merge-Sorted-Array.md" >}})Easy46.6%
0147Insertion Sort List[Go]({{< relref "/ChapterFour/0100~0199/0147.Insertion-Sort-List.md" >}})MediumO(n^2)O(1)❤️51.0%
0148Sort List[Go]({{< relref "/ChapterFour/0100~0199/0148.Sort-List.md" >}})MediumO(n log n)O(log n)❤️55.1%
0164Maximum Gap[Go]({{< relref "/ChapterFour/0100~0199/0164.Maximum-Gap.md" >}})HardO(n log n)O(log n)❤️43.3%
0169Majority Element[Go]({{< relref "/ChapterFour/0100~0199/0169.Majority-Element.md" >}})Easy63.9%
0179Largest Number[Go]({{< relref "/ChapterFour/0100~0199/0179.Largest-Number.md" >}})MediumO(n log n)O(log n)❤️34.5%
0215Kth Largest Element in an Array[Go]({{< relref "/ChapterFour/0200~0299/0215.Kth-Largest-Element-in-an-Array.md" >}})Medium66.1%
0217Contains Duplicate[Go]({{< relref "/ChapterFour/0200~0299/0217.Contains-Duplicate.md" >}})Easy61.4%
0220Contains Duplicate III[Go]({{< relref "/ChapterFour/0200~0299/0220.Contains-Duplicate-III.md" >}})HardO(n log n)O(1)❤️22.1%
0229Majority Element II[Go]({{< relref "/ChapterFour/0200~0299/0229.Majority-Element-II.md" >}})Medium45.0%
0242Valid Anagram[Go]({{< relref "/ChapterFour/0200~0299/0242.Valid-Anagram.md" >}})EasyO(n)O(n)63.0%
0268Missing Number[Go]({{< relref "/ChapterFour/0200~0299/0268.Missing-Number.md" >}})Easy62.5%
0274H-Index[Go]({{< relref "/ChapterFour/0200~0299/0274.H-Index.md" >}})MediumO(n)O(n)38.3%
0324Wiggle Sort II[Go]({{< relref "/ChapterFour/0300~0399/0324.Wiggle-Sort-II.md" >}})MediumO(n)O(n)❤️33.3%
0347Top K Frequent Elements[Go]({{< relref "/ChapterFour/0300~0399/0347.Top-K-Frequent-Elements.md" >}})Medium64.2%
0349Intersection of Two Arrays[Go]({{< relref "/ChapterFour/0300~0399/0349.Intersection-of-Two-Arrays.md" >}})EasyO(n)O(n)70.9%
0350Intersection of Two Arrays II[Go]({{< relref "/ChapterFour/0300~0399/0350.Intersection-of-Two-Arrays-II.md" >}})EasyO(n)O(n)56.0%
0354Russian Doll Envelopes[Go]({{< relref "/ChapterFour/0300~0399/0354.Russian-Doll-Envelopes.md" >}})Hard38.0%
0368Largest Divisible Subset[Go]({{< relref "/ChapterFour/0300~0399/0368.Largest-Divisible-Subset.md" >}})Medium41.5%
0378Kth Smallest Element in a Sorted Matrix[Go]({{< relref "/ChapterFour/0300~0399/0378.Kth-Smallest-Element-in-a-Sorted-Matrix.md" >}})Medium61.7%
0389Find the Difference[Go]({{< relref "/ChapterFour/0300~0399/0389.Find-the-Difference.md" >}})Easy59.9%
0414Third Maximum Number[Go]({{< relref "/ChapterFour/0400~0499/0414.Third-Maximum-Number.md" >}})Easy33.2%
0435Non-overlapping Intervals[Go]({{< relref "/ChapterFour/0400~0499/0435.Non-overlapping-Intervals.md" >}})Medium50.3%
0436Find Right Interval[Go]({{< relref "/ChapterFour/0400~0499/0436.Find-Right-Interval.md" >}})Medium50.8%
0451Sort Characters By Frequency[Go]({{< relref "/ChapterFour/0400~0499/0451.Sort-Characters-By-Frequency.md" >}})Medium70.1%
0455Assign Cookies[Go]({{< relref "/ChapterFour/0400~0499/0455.Assign-Cookies.md" >}})Easy49.9%
0462Minimum Moves to Equal Array Elements II[Go]({{< relref "/ChapterFour/0400~0499/0462.Minimum-Moves-to-Equal-Array-Elements-II.md" >}})Medium60.0%
0475Heaters[Go]({{< relref "/ChapterFour/0400~0499/0475.Heaters.md" >}})Medium36.5%
0506Relative Ranks[Go]({{< relref "/ChapterFour/0500~0599/0506.Relative-Ranks.md" >}})Easy60.5%
0524Longest Word in Dictionary through Deleting[Go]({{< relref "/ChapterFour/0500~0599/0524.Longest-Word-in-Dictionary-through-Deleting.md" >}})MediumO(n)O(1)51.0%
0532K-diff Pairs in an Array[Go]({{< relref "/ChapterFour/0500~0599/0532.K-diff-Pairs-in-an-Array.md" >}})Medium41.2%
0561Array Partition[Go]({{< relref "/ChapterFour/0500~0599/0561.Array-Partition.md" >}})Easy77.2%
0581Shortest Unsorted Continuous Subarray[Go]({{< relref "/ChapterFour/0500~0599/0581.Shortest-Unsorted-Continuous-Subarray.md" >}})Medium36.4%
0594Longest Harmonious Subsequence[Go]({{< relref "/ChapterFour/0500~0599/0594.Longest-Harmonious-Subsequence.md" >}})Easy53.5%
0611Valid Triangle Number[Go]({{< relref "/ChapterFour/0600~0699/0611.Valid-Triangle-Number.md" >}})Medium50.5%
0628Maximum Product of Three Numbers[Go]({{< relref "/ChapterFour/0600~0699/0628.Maximum-Product-of-Three-Numbers.md" >}})Easy45.9%
0632Smallest Range Covering Elements from K Lists[Go]({{< relref "/ChapterFour/0600~0699/0632.Smallest-Range-Covering-Elements-from-K-Lists.md" >}})Hard61.0%
0645Set Mismatch[Go]({{< relref "/ChapterFour/0600~0699/0645.Set-Mismatch.md" >}})Easy42.7%
0658Find K Closest Elements[Go]({{< relref "/ChapterFour/0600~0699/0658.Find-K-Closest-Elements.md" >}})Medium46.8%
0692Top K Frequent Words[Go]({{< relref "/ChapterFour/0600~0699/0692.Top-K-Frequent-Words.md" >}})Medium57.2%
0710Random Pick with Blacklist[Go]({{< relref "/ChapterFour/0700~0799/0710.Random-Pick-with-Blacklist.md" >}})HardO(n)O(n)33.5%
0719Find K-th Smallest Pair Distance[Go]({{< relref "/ChapterFour/0700~0799/0719.Find-K-th-Smallest-Pair-Distance.md" >}})Hard36.7%
0720Longest Word in Dictionary[Go]({{< relref "/ChapterFour/0700~0799/0720.Longest-Word-in-Dictionary.md" >}})Medium52.0%
0726Number of Atoms[Go]({{< relref "/ChapterFour/0700~0799/0726.Number-of-Atoms.md" >}})Hard52.1%
0747Largest Number At Least Twice of Others[Go]({{< relref "/ChapterFour/0700~0799/0747.Largest-Number-At-Least-Twice-of-Others.md" >}})Easy47.1%
0767Reorganize String[Go]({{< relref "/ChapterFour/0700~0799/0767.Reorganize-String.md" >}})MediumO(n log n)O(log n)❤️52.9%
0786K-th Smallest Prime Fraction[Go]({{< relref "/ChapterFour/0700~0799/0786.K-th-Smallest-Prime-Fraction.md" >}})Medium51.6%
0791Custom Sort String[Go]({{< relref "/ChapterFour/0700~0799/0791.Custom-Sort-String.md" >}})Medium69.1%
0792Number of Matching Subsequences[Go]({{< relref "/ChapterFour/0700~0799/0792.Number-of-Matching-Subsequences.md" >}})Medium51.6%
0825Friends Of Appropriate Ages[Go]({{< relref "/ChapterFour/0800~0899/0825.Friends-Of-Appropriate-Ages.md" >}})Medium46.3%
0826Most Profit Assigning Work[Go]({{< relref "/ChapterFour/0800~0899/0826.Most-Profit-Assigning-Work.md" >}})Medium44.9%
0846Hand of Straights[Go]({{< relref "/ChapterFour/0800~0899/0846.Hand-of-Straights.md" >}})Medium56.2%
0853Car Fleet[Go]({{< relref "/ChapterFour/0800~0899/0853.Car-Fleet.md" >}})MediumO(n log n)O(log n)50.3%
0869Reordered Power of 2[Go]({{< relref "/ChapterFour/0800~0899/0869.Reordered-Power-of-2.md" >}})Medium63.5%
0870Advantage Shuffle[Go]({{< relref "/ChapterFour/0800~0899/0870.Advantage-Shuffle.md" >}})Medium51.8%
0881Boats to Save People[Go]({{< relref "/ChapterFour/0800~0899/0881.Boats-to-Save-People.md" >}})Medium53.1%
0888Fair Candy Swap[Go]({{< relref "/ChapterFour/0800~0899/0888.Fair-Candy-Swap.md" >}})Easy60.7%
0891Sum of Subsequence Widths[Go]({{< relref "/ChapterFour/0800~0899/0891.Sum-of-Subsequence-Widths.md" >}})Hard36.6%
0910Smallest Range II[Go]({{< relref "/ChapterFour/0900~0999/0910.Smallest-Range-II.md" >}})Medium35.1%
0922Sort Array By Parity II[Go]({{< relref "/ChapterFour/0900~0999/0922.Sort-Array-By-Parity-II.md" >}})EasyO(n)O(1)70.7%
09233Sum With Multiplicity[Go]({{< relref "/ChapterFour/0900~0999/0923.3Sum-With-Multiplicity.md" >}})Medium45.3%
0969Pancake Sorting[Go]({{< relref "/ChapterFour/0900~0999/0969.Pancake-Sorting.md" >}})MediumO(n log n)O(log n)❤️70.1%
0973K Closest Points to Origin[Go]({{< relref "/ChapterFour/0900~0999/0973.K-Closest-Points-to-Origin.md" >}})MediumO(n log n)O(log n)65.7%
0976Largest Perimeter Triangle[Go]({{< relref "/ChapterFour/0900~0999/0976.Largest-Perimeter-Triangle.md" >}})EasyO(n log n)O(log n)54.6%
0977Squares of a Sorted Array[Go]({{< relref "/ChapterFour/0900~0999/0977.Squares-of-a-Sorted-Array.md" >}})Easy71.9%
1005Maximize Sum Of Array After K Negations[Go]({{< relref "/ChapterFour/1000~1099/1005.Maximize-Sum-Of-Array-After-K-Negations.md" >}})Easy50.9%
1030Matrix Cells in Distance Order[Go]({{< relref "/ChapterFour/1000~1099/1030.Matrix-Cells-in-Distance-Order.md" >}})EasyO(n^2)O(1)69.7%
1040Moving Stones Until Consecutive II[Go]({{< relref "/ChapterFour/1000~1099/1040.Moving-Stones-Until-Consecutive-II.md" >}})Medium55.9%
1051Height Checker[Go]({{< relref "/ChapterFour/1000~1099/1051.Height-Checker.md" >}})Easy75.6%
1054Distant Barcodes[Go]({{< relref "/ChapterFour/1000~1099/1054.Distant-Barcodes.md" >}})MediumO(n log n)O(log n)❤️45.8%
1122Relative Sort Array[Go]({{< relref "/ChapterFour/1100~1199/1122.Relative-Sort-Array.md" >}})Easy68.6%
1170Compare Strings by Frequency of the Smallest Character[Go]({{< relref "/ChapterFour/1100~1199/1170.Compare-Strings-by-Frequency-of-the-Smallest-Character.md" >}})Medium61.5%
1200Minimum Absolute Difference[Go]({{< relref "/ChapterFour/1200~1299/1200.Minimum-Absolute-Difference.md" >}})Easy69.6%
1235Maximum Profit in Job Scheduling[Go]({{< relref "/ChapterFour/1200~1299/1235.Maximum-Profit-in-Job-Scheduling.md" >}})Hard53.4%
1296Divide Array in Sets of K Consecutive Numbers[Go]({{< relref "/ChapterFour/1200~1299/1296.Divide-Array-in-Sets-of-K-Consecutive-Numbers.md" >}})Medium56.5%
1300Sum of Mutated Array Closest to Target[Go]({{< relref "/ChapterFour/1300~1399/1300.Sum-of-Mutated-Array-Closest-to-Target.md" >}})Medium43.6%
1305All Elements in Two Binary Search Trees[Go]({{< relref "/ChapterFour/1300~1399/1305.All-Elements-in-Two-Binary-Search-Trees.md" >}})Medium79.8%
1329Sort the Matrix Diagonally[Go]({{< relref "/ChapterFour/1300~1399/1329.Sort-the-Matrix-Diagonally.md" >}})Medium83.3%
1337The K Weakest Rows in a Matrix[Go]({{< relref "/ChapterFour/1300~1399/1337.The-K-Weakest-Rows-in-a-Matrix.md" >}})Easy72.1%
1353Maximum Number of Events That Can Be Attended[Go]({{< relref "/ChapterFour/1300~1399/1353.Maximum-Number-of-Events-That-Can-Be-Attended.md" >}})Medium32.5%
1383Maximum Performance of a Team[Go]({{< relref "/ChapterFour/1300~1399/1383.Maximum-Performance-of-a-Team.md" >}})Hard48.5%
1385Find the Distance Value Between Two Arrays[Go]({{< relref "/ChapterFour/1300~1399/1385.Find-the-Distance-Value-Between-Two-Arrays.md" >}})Easy66.5%
1464Maximum Product of Two Elements in an Array[Go]({{< relref "/ChapterFour/1400~1499/1464.Maximum-Product-of-Two-Elements-in-an-Array.md" >}})Easy79.9%
1465Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts[Go]({{< relref "/ChapterFour/1400~1499/1465.Maximum-Area-of-a-Piece-of-Cake-After-Horizontal-and-Vertical-Cuts.md" >}})Medium40.9%
1608Special 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" >}})Easy60.5%
1619Mean of Array After Removing Some Elements[Go]({{< relref "/ChapterFour/1600~1699/1619.Mean-of-Array-After-Removing-Some-Elements.md" >}})Easy65.7%
1636Sort Array by Increasing Frequency[Go]({{< relref "/ChapterFour/1600~1699/1636.Sort-Array-by-Increasing-Frequency.md" >}})Easy69.5%
1647Minimum Deletions to Make Character Frequencies Unique[Go]({{< relref "/ChapterFour/1600~1699/1647.Minimum-Deletions-to-Make-Character-Frequencies-Unique.md" >}})Medium59.1%
1648Sell Diminishing-Valued Colored Balls[Go]({{< relref "/ChapterFour/1600~1699/1648.Sell-Diminishing-Valued-Colored-Balls.md" >}})Medium30.5%
1657Determine if Two Strings Are Close[Go]({{< relref "/ChapterFour/1600~1699/1657.Determine-if-Two-Strings-Are-Close.md" >}})Medium56.3%
1665Minimum Initial Energy to Finish Tasks[Go]({{< relref "/ChapterFour/1600~1699/1665.Minimum-Initial-Energy-to-Finish-Tasks.md" >}})Hard56.3%
1679Max Number of K-Sum Pairs[Go]({{< relref "/ChapterFour/1600~1699/1679.Max-Number-of-K-Sum-Pairs.md" >}})Medium57.3%
1691Maximum Height by Stacking Cuboids[Go]({{< relref "/ChapterFour/1600~1699/1691.Maximum-Height-by-Stacking-Cuboids.md" >}})Hard54.4%
1710Maximum Units on a Truck[Go]({{< relref "/ChapterFour/1700~1799/1710.Maximum-Units-on-a-Truck.md" >}})Easy73.8%
1818Minimum Absolute Sum Difference[Go]({{< relref "/ChapterFour/1800~1899/1818.Minimum-Absolute-Sum-Difference.md" >}})Medium30.4%
1846Maximum Element After Decreasing and Rearranging[Go]({{< relref "/ChapterFour/1800~1899/1846.Maximum-Element-After-Decreasing-and-Rearranging.md" >}})Medium58.9%
1877Minimize Maximum Pair Sum in Array[Go]({{< relref "/ChapterFour/1800~1899/1877.Minimize-Maximum-Pair-Sum-in-Array.md" >}})Medium79.9%
1984Minimum Difference Between Highest and Lowest of K Scores[Go]({{< relref "/ChapterFour/1900~1999/1984.Minimum-Difference-Between-Highest-and-Lowest-of-K-Scores.md" >}})Easy54.4%
2037Minimum Number of Moves to Seat Everyone[Go]({{< relref "/ChapterFour/2000~2099/2037.Minimum-Number-of-Moves-to-Seat-Everyone.md" >}})Easy82.1%
2164Sort Even and Odd Indices Independently[Go]({{< relref "/ChapterFour/2100~2199/2164.Sort-Even-and-Odd-Indices-Independently.md" >}})Easy65.0%
2165Smallest Value of the Rearranged Number[Go]({{< relref "/ChapterFour/2100~2199/2165.Smallest-Value-of-the-Rearranged-Number.md" >}})Medium51.4%
2171Removing Minimum Number of Magic Beans[Go]({{< relref "/ChapterFour/2100~2199/2171.Removing-Minimum-Number-of-Magic-Beans.md" >}})Medium42.1%
------------------------------------------------------------------------------------------------------------------------------------------------

<div style="display: flex;justify-content: space-between;align-items: center;"> <p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Hash_Table/">⬅️上一页</a></p> <p><a href="https://books.halfrost.com/leetcode/ChapterTwo/Bit_Manipulation/">下一页➡️</a></p> </div>