![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
linked list
feeeeeeet
这个作者很懒,什么都没留下…
展开
-
Leetcode 19. Remove Nth Node From End of List
Faster pointer go first, after n steps there are len-n numbers. Then two pointers go together until there is no number faster pointer points to(len-n steps). Slower pointer points to the n-th node fro...原创 2018-11-14 09:09:36 · 61 阅读 · 0 评论 -
Leetcode 25. Reverse Nodes in k-Group
extend from Leetcode 240(q)-1(head)-2-3-4-5-60(q)-2-1(head)-3-4-5-60-3-2-1(q)-4(head)-5-6class Solution { public ListNode reverseKGroup(ListNode head, int k) { ListNode res=new ListNode(0);...原创 2018-11-19 06:19:57 · 58 阅读 · 0 评论 -
Leetcode 21. Merge Two Sorted Lists
Complicated VersionPart 1 should be the first part, otherwise the program couldn’t pass the following case. In the last iteration, we have flag=0 and l2==null, so the program can’t run part 2.input...原创 2018-11-15 03:44:32 · 65 阅读 · 0 评论 -
Leetcode 24. Swap Nodes in Pairs
2 solutions - use two extra pointers & recursiveSolution 1 use two extra pointersclass Solution { public ListNode swapPairs(ListNode head) { ListNode res=new ListNode(-1); re...原创 2018-11-15 06:17:42 · 173 阅读 · 0 评论 -
Leetcode 82&83. Remove Duplicates from Sorted List I & II
recursion can be used in IIdifference between pre=cur(the same node) and pre.val=cur.val (two nodes have the same number)Remove Duplicates from Sorted List I2 solutionsslow version# Definition fo...原创 2018-12-31 00:24:20 · 111 阅读 · 0 评论 -
Leetcode 86. Partition List
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def partition(self, head, x): """ ...原创 2018-12-31 07:08:29 · 92 阅读 · 0 评论 -
Leetcode 61. Rotate List
Calculate the length of the list and use k%length.# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution...原创 2018-12-26 00:29:28 · 82 阅读 · 0 评论