Algorithm in LeetCode —— Sort

Sort 的 Tips:

  • 深刻的理解多路快排。第 75 题。
  • 链表的排序,插入排序(第 147 题)和归并排序(第 148 题)
  • 桶排序和基数排序。第 164 题。
  • “摆动排序”。第 324 题。
  • 两两不相邻的排序。第 767 题,第 1054 题。
  • “饼子排序”。第 969 题。
TitleSolutionDifficultyTimeSpace收藏
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)