摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2015-11-16 19:50 AprilCheny 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2015-11-16 18:58 AprilCheny 阅读(304) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2015-11-16 16:19 AprilCheny 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list inO(nlogn) time using constant space complexity.Subscribeto see which companies asked this question解法:这题和Insertion Sort List链表插入排序一... 阅读全文
posted @ 2015-11-16 15:25 AprilCheny 阅读(564) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort.Subscribeto see which companies asked this question解法:设置3个指针:应插入位置的前一个节点first、当前处理节点third和其前一个节点second,设置辅助节点h... 阅读全文
posted @ 2015-11-16 13:04 AprilCheny 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文
posted @ 2015-11-16 10:41 AprilCheny 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-11-16 10:17 AprilCheny 阅读(227) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2015-11-16 09:24 AprilCheny 阅读(174) 评论(0) 推荐(0) 编辑