上一页 1 ··· 8 9 10 11 12 13 下一页
摘要: Description Insert a value in a sorted linked list. Examples L = null, insert 1, return 1 -> null L = 1 -> 3 -> 5 -> null, insert 2, return 1 -> 2 -> 阅读全文
posted @ 2018-02-23 01:43 davidnyc 阅读(195) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->... 阅读全文
posted @ 2018-02-22 03:20 davidnyc 阅读(138) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/delete-node-in-a-linked-list/description/Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked... 阅读全文
posted @ 2018-02-22 00:16 davidnyc 阅读(116) 评论(0) 推荐(0)
摘要: 千万注意,不要遍历两遍 什么 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)
摘要: time complexity: offer(), size(), isEmpty(): o(1) for poll and peek: worst case: offer n times, peek/poll only once: o(n) average case: offer n times, 阅读全文
posted @ 2018-02-20 23:50 davidnyc 阅读(178) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 下一页