ListNode
unshaven111
这个作者很懒,什么都没留下…
展开
-
82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2-...原创 2018-11-09 18:11:57 · 84 阅读 · 0 评论 -
19. Remove Nth Node From End of ListV
Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l...原创 2018-11-07 10:56:32 · 72 阅读 · 0 评论 -
merge two linkedList
第一种方法是非递归: ListNode* merge2Lists(ListNode* node1,ListNode* node2){ if(node1==NULL) return node2; if(node2==NULL) return node1; ListNode* res = node1->val < node2->...原创 2018-11-07 14:07:50 · 169 阅读 · 0 评论 -
23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->...原创 2018-11-07 15:33:50 · 68 阅读 · 0 评论 -
92.Reverse Linked List II
单链表的尾插法, 1->2->3->4->5->6 如果要变成 1->5->4->3->2->6 其实就是每次都把一个node插到当前的头部 1->2->3->4->5->6 head指向1,prev指向2,cur指向3 prev->next = cur->next; cu原创 2018-11-13 16:33:25 · 50 阅读 · 0 评论 -
61. Rotate List
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->NULL Explanati...原创 2018-11-16 20:43:05 · 55 阅读 · 0 评论 -
25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of n...原创 2018-11-16 22:03:40 · 78 阅读 · 0 评论