摘要:
千万注意,不要遍历两遍 什么 while(oddcurr) while(evencurr) 因为underline 的链表是一个,所以遍历第一遍之后就已经把 next 的关系搞混了, 后面那个遍历就不准确了。 阅读全文
posted @ 2018-02-21 23:32
davidnyc
阅读(147)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/merge-two-sorted-lists/description/Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two ... 阅读全文
posted @ 2018-02-21 22:58
davidnyc
阅读(125)
评论(0)
推荐(0)
摘要:
2-1-4-3-5 5 自己就弹了,所以没有后面的处理,所以(head=3)head.next 还是 直接连 last pop newhead(5) 所以是 2-1-4-3-5 要深刻理解当时stack 里 head = 3 newhead=5 这一点! 阅读全文
posted @ 2018-02-21 12:54
davidnyc
阅读(121)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/linked-list-cycle/description/ time: o(n) space: o(1) Follow up:Can you solve it without using extra space? if you use e 阅读全文
posted @ 2018-02-21 12:04
davidnyc
阅读(121)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2018-02-21 11:29
davidnyc
阅读(102)
评论(0)
推荐(0)
摘要:
recursive: assume Node2 is the head, subproblem return: null<-Node3 <- Node4 then you want to change to ListNode newHead = reverse(head.next) will gen 阅读全文
posted @ 2018-02-21 11:11
davidnyc
阅读(115)
评论(0)
推荐(0)
浙公网安备 33010602011771号