2.04 ✅ Linked List

Linked List #

  • 巧妙的构造虚拟头结点。可以使遍历处理逻辑更加统一。
  • 灵活使用递归。构造递归条件,使用递归可以巧妙的解题。不过需要注意有些题目不能使用递归,因为递归深度太深会导致超时和栈溢出。
  • 链表区间逆序。第 92 题。
  • 链表寻找中间节点。第 876 题。链表寻找倒数第 n 个节点。第 19 题。只需要一次遍历就可以得到答案。
  • 合并 K 个有序链表。第 21 题,第 23 题。
  • 链表归类。第 86 题,第 328 题。
  • 链表排序,时间复杂度要求 O(n * log n),空间复杂度 O(1)。只有一种做法,归并排序,至顶向下归并。第 148 题。
  • 判断链表是否存在环,如果有环,输出环的交叉点的下标;判断 2 个链表是否有交叉点,如果有交叉点,输出交叉点。第 141 题,第 142 题,第 160 题。
No.TitleSolutionDifficultyTimeComplexitySpaceComplexityFavoriteAcceptance
0002Add Two NumbersGoMediumO(n)O(1)40.4%
0019Remove Nth Node From End of ListGoMediumO(n)O(1)41.1%
0021Merge Two Sorted ListsGoEasyO(log n)O(1)62.5%
0023Merge k Sorted ListsGoHardO(log n)O(1)❤️49.8%
0024Swap Nodes in PairsGoMediumO(n)O(1)61.3%
0025Reverse Nodes in k-GroupGoHardO(log n)O(1)❤️54.7%
0061Rotate ListGoMediumO(n)O(1)36.1%
0082Remove Duplicates from Sorted List IIGoMediumO(n)O(1)45.9%
0083Remove Duplicates from Sorted ListGoEasyO(n)O(1)50.6%
0086Partition ListGoMediumO(n)O(1)❤️52.0%
0092Reverse Linked List IIGoMediumO(n)O(1)❤️45.4%
0109Convert Sorted List to Binary Search TreeGoMediumO(log n)O(n)60.2%
0114Flatten Binary Tree to Linked ListGoMedium61.8%
0116Populating Next Right Pointers in Each NodeGoMedium60.4%
0138Copy List with Random PointerGoMedium51.4%
0141Linked List CycleGoEasyO(n)O(1)❤️47.5%
0142Linked List Cycle IIGoMediumO(n)O(1)❤️48.8%
0143Reorder ListGoMediumO(n)O(1)❤️52.6%
0146LRU CacheGoMedium40.7%
0147Insertion Sort ListGoMediumO(n)O(1)❤️51.1%
0148Sort ListGoMediumO(n log n)O(n)❤️55.1%
0160Intersection of Two Linked ListsGoEasyO(n)O(1)❤️54.4%
0203Remove Linked List ElementsGoEasyO(n)O(1)46.0%
0206Reverse Linked ListGoEasyO(n)O(1)73.6%
0234Palindrome Linked ListGoEasyO(n)O(1)50.2%
0237Delete Node in a Linked ListGoMediumO(n)O(1)76.0%
0328Odd Even Linked ListGoMediumO(n)O(1)61.3%
0382Linked List Random NodeGoMedium62.8%
0445Add Two Numbers IIGoMediumO(n)O(n)59.6%
0460LFU CacheGoHard43.0%
0622Design Circular QueueGoMedium51.5%
0705Design HashSetGoEasy65.6%
0706Design HashMapGoEasy64.7%
0707Design Linked ListGoMediumO(n)O(1)27.7%
0725Split Linked List in PartsGoMediumO(n)O(1)57.2%
0817Linked List ComponentsGoMediumO(n)O(1)57.7%
0876Middle of the Linked ListGoEasyO(n)O(1)❤️75.7%
1019Next Greater Node In Linked ListGoMediumO(n)O(1)59.9%
1171Remove Zero Sum Consecutive Nodes from Linked ListGoMedium43.2%
1290Convert Binary Number in a Linked List to IntegerGoEasy82.1%
1669Merge In Between Linked ListsGoMedium73.7%
1670Design Front Middle Back QueueGoMedium57.2%
1721Swapping Nodes in a Linked ListGoMedium67.1%
2181Merge Nodes in Between ZerosGoMedium86.3%
——————————————————————-——-—————-—————————-————-————-

⬅️上一页

下一页➡️

Calendar Apr 8, 2023
Edit Edit this page
本站总访问量:  次 您是本站第  位访问者