Algorithm in LeetCode —— Sort

Sort Tips:

  • Develop a deep understanding of multi-way quicksort. Problem 75.
  • Sorting linked lists: insertion sort (Problem 147) and merge sort (Problem 148).
  • Bucket sort and radix sort. Problem 164.
  • “Wiggle Sort”. Problem 324.
  • Sorting so that no two identical elements are adjacent. Problems 767 and 1054.
  • “Pancake Sorting”. Problem 969.
TitleSolutionDifficultyTimeSpaceFavorites
56. Merge IntervalsGoMediumO(n log n)O(log n)
57. Insert IntervalGoHardO(n)O(1)
75. Sort ColorsGoMediumO(n)O(1)❤️
147. Insertion Sort ListGoMediumO(n)O(1)❤️
148. Sort ListGoMediumO(n log n)O(log n)❤️
164. Maximum GapGoHardO(n log n)O(log n)❤️
179. Largest NumberGoMediumO(n log n)O(log n)❤️
220. Contains Duplicate IIIGoMediumO(n^2)O(1)
242. Valid AnagramGoEasyO(n)O(n)
274. H-IndexGoMediumO(n)O(n)
324. Wiggle Sort IIGoMediumO(n)O(n)❤️
349. Intersection of Two ArraysGoEasyO(n)O(n)
350. Intersection of Two Arrays IIGoEasyO(n)O(n)
524. Longest Word in Dictionary through DeletingGoMediumO(n)O(1)
767. Reorganize StringGoMediumO(n log n)O(log n)❤️
853. Car FleetGoMediumO(n log n)O(log n)
710. Random Pick with BlacklistGoHardO(n)O(n)
922. Sort Array By Parity IIGoEasyO(n)O(1)
969. Pancake SortingGoMediumO(n log n)O(log n)❤️
973. K Closest Points to OriginGoMediumO(n log n)O(log n)
976. Largest Perimeter TriangleGoEasyO(n log n)O(log n)
1030. Matrix Cells in Distance OrderGoEasyO(n^2)O(1)
1054. Distant BarcodesGoMediumO(n log n)O(log n)