上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-06-18 15:16 朱传林 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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-06-18 09:08 朱传林 阅读(87) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2015-06-18 08:15 朱传林 阅读(139) 评论(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./** * Def... 阅读全文
posted @ 2015-06-18 08:12 朱传林 阅读(112) 评论(0) 推荐(0) 编辑
摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2015-06-18 08:11 朱传林 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文
posted @ 2015-06-17 15:42 朱传林 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list inO(nlogn) time using constant space complexity. 分析:排序算法中,堆排序、归并排序、快速排序、希尔排序的时间复杂度是nlogn,堆排序和归并排序对下标依赖性比较强,比较适合顺序表的排序,对链表处理起来比较... 阅读全文
posted @ 2015-06-17 09:45 朱传林 阅读(153) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文
posted @ 2015-06-17 09:42 朱传林 阅读(124) 评论(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-06-16 14:41 朱传林 阅读(157) 评论(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-06-16 14:40 朱传林 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页