上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 21 下一页
摘要: 题目链接 题目要求: Sort a linked list inO(nlogn) time using constant space complexity. 满足O(nlogn)时间复杂度的有快排、归并排序、堆排序。在这里采用的是归并排序(空间复杂度O(logn)),具体程序如下: 1 /... 阅读全文
posted @ 2015-06-27 18:33 峰子_仰望阳光 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 下边讨论暂不包括尾节点。 一般来说,我们要删除链表中的一个节点是需要知道其上一节点的。但我们真的需要吗? 其实我们可以将待删节点的下一节点的值和指向的下一节点赋予待删节点,然后删除待删节点的下一节点。具体示例程序如下: 1 //O(1)时间删除链表节点,从无头单链表中删除节点 2 void ... 阅读全文
posted @ 2015-06-27 17:01 峰子_仰望阳光 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目要求: Given a list, rotate the list to the right bykplaces, wherekis non-negative. For example: Given1->2->3->4->5->NULLandk=2, return4->5... 阅读全文
posted @ 2015-06-27 16:26 峰子_仰望阳光 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目要求: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list. If the number of nodes is not a multip... 阅读全文
posted @ 2015-06-27 11:56 峰子_仰望阳光 阅读(165) 评论(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 ... 阅读全文
posted @ 2015-06-27 10:55 峰子_仰望阳光 阅读(175) 评论(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 p... 阅读全文
posted @ 2015-06-26 17:53 峰子_仰望阳光 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1.Remove Duplicates from Sorted List 题目链接 题目要求: Given a sorted linked list, delete all duplicates such that each element appear onlyonce. For ex... 阅读全文
posted @ 2015-06-26 16:13 峰子_仰望阳光 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 此题扩展:链表有环,如何判断相交? 参考资料: 编程判断两个链表是否相交 面试精选:链表问题集锦 题目链接 题目要求: Write a program to find the node at which the intersection of two singly linke... 阅读全文
posted @ 2015-06-26 15:46 峰子_仰望阳光 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目要求: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes co... 阅读全文
posted @ 2015-06-26 15:07 峰子_仰望阳光 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1.Merge Two Sorted Lists 题目链接 题目要求: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together t... 阅读全文
posted @ 2015-06-26 11:40 峰子_仰望阳光 阅读(332) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 21 下一页