摘要: 题目:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->... 阅读全文
posted @ 2014-07-23 23:37 爱做饭的小莹子 阅读(2829) 评论(0) 推荐(1) 编辑
摘要: 题目:Sort a linked list using insertion sort.题解:Insertion Sort就是把一个一个元素往已排好序的list中插入的过程。初始时,sorted list是空,把一个元素插入sorted list中。然后,在每一次插入过程中,都是找到最合适位置进行插... 阅读全文
posted @ 2014-07-23 10:45 爱做饭的小莹子 阅读(4560) 评论(1) 推荐(0) 编辑
摘要: 题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve t... 阅读全文
posted @ 2014-07-23 10:21 爱做饭的小莹子 阅读(4114) 评论(0) 推荐(1) 编辑
摘要: 题目: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->4->5, and n = 2. Af... 阅读全文
posted @ 2014-07-23 09:16 爱做饭的小莹子 阅读(4618) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra spac... 阅读全文
posted @ 2014-07-23 05:32 爱做饭的小莹子 阅读(3256) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题解:这道题连带着II是很经典的,在看CC150时候,纠结这个问题纠结了很久... 阅读全文
posted @ 2014-07-23 05:03 爱做饭的小莹子 阅读(2119) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1... 阅读全文
posted @ 2014-07-23 04:32 爱做饭的小莹子 阅读(2979) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3-... 阅读全文
posted @ 2014-07-23 03:56 爱做饭的小莹子 阅读(1708) 评论(0) 推荐(0) 编辑
摘要: 题目: 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 lists. 题解:... 阅读全文
posted @ 2014-07-23 03:24 爱做饭的小莹子 阅读(3424) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.http... 阅读全文
posted @ 2014-07-23 03:01 爱做饭的小莹子 阅读(5797) 评论(0) 推荐(0) 编辑
摘要: 题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should ... 阅读全文
posted @ 2014-07-23 00:45 爱做饭的小莹子 阅读(9892) 评论(1) 推荐(1) 编辑