链表
文章平均质量分 74
哎-哭泣的鱼
这个作者很懒,什么都没留下…
展开
-
【九度】题目1524:复杂链表的复制
题目描述:输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点)。输入:输入可能包含多个测试样例,输入以EOF结束。对于每个测试案例,输入的第一行为一个整数n (1接下来有n个数,表示链表节点中的值。接下来有n个数Ti,Ti表示第i个节点的另一个指针指向。Ti = 0 表示这个指针为NULL。原创 2013-12-14 00:13:35 · 731 阅读 · 0 评论 -
【九度】题目1505:两个链表的第一个公共结点
题目描述:输入两个链表,找出它们的第一个公共结点。输入:输入可能包含多个测试样例。对于每个测试案例,输入的第一行为两个整数m和n(1接下来的两行,第一行为第一个链表的所有元素,中间用空格隔开。第二行为第二个链表的所有元素,中间用空格隔开。输出:对应每个测试案例,输出两个链表的第一个公共结点的值。如果两个链表没有公共结点原创 2013-12-12 17:13:07 · 860 阅读 · 0 评论 -
【九度】链表整理
1415 不一样的循环队列1181 遍历链表1503 二叉搜索树与双向链表1505 两个链表的第一个公共结点1511 从尾到头打印链表1517 链表中倒数第k个结点1518 反转链表1519 合并两个排序的链表1524 复杂链表的复制1415 不一样的循环队列,其实是考察链表的底层实现。从这个题目说起,写一写链表的底层实现。其他的都是对链表的一些基本操作原创 2013-12-11 16:27:51 · 765 阅读 · 0 评论 -
【九度】题目1181:遍历链表
题目描述:建立一个升序链表并遍历输出。输入:输入的每个案例中第一行包括1个整数:n(1输出:可能有多组测试数据,对于每组数据,将n个整数建立升序链表,之后遍历链表并输出。样例输入:43 5 7 9样例输出:3 5 7 9来源:2000年华中科技大学计算机研究生机试真题如果用数组的话,使用快排原创 2013-12-12 16:40:22 · 869 阅读 · 0 评论 -
【LeetCode】Intersection of Two Linked Lists
1、【LeetCode】Intersection of Two Linked Lists Total Accepted: 16034 Total Submissions: 58142 My Submissions Question Solution Write a program to find the node at which the intersection of two singl原创 2015-02-13 16:26:10 · 772 阅读 · 0 评论 -
【LeetCode】Add Two Numbers
Add Two Numbers Total Accepted: 17137 Total Submissions: 75794 My SubmissionsYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each o原创 2014-07-17 15:53:10 · 674 阅读 · 0 评论 -
【LeetCode】Merge k Sorted Lists
Merge k Sorted Lists Total Accepted: 13489 Total Submissions: 61228 My SubmissionsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.【解题思路】1、参考Me原创 2014-07-16 15:09:38 · 794 阅读 · 0 评论 -
【LeetCode】Merge Two Sorted Lists
Merge Two Sorted Lists Total Accepted: 18308 Total Submissions: 55982 My SubmissionsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the原创 2014-07-15 10:24:50 · 752 阅读 · 0 评论 -
【LeetCode】Convert Sorted Array to Binary Search Tree && Convert Sorted List to Binary Search Tree
1、Convert Sorted Array to Binary Search Tree Total Accepted: 8749 Total Submissions: 27493 My SubmissionsGiven an array where elements are sorted in ascending order, convert it to a height balance原创 2014-03-16 13:24:18 · 912 阅读 · 0 评论 -
【LeetCode】Rotate List
Rotate List Total Accepted: 6485 Total Submissions: 30150 My SubmissionsGiven a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL an原创 2014-03-14 10:14:37 · 754 阅读 · 0 评论 -
【LeetCode】Swap Nodes in Pairs && Reverse Nodes in k-Group
1、Swap Nodes in Pairs Total Accepted: 9085 Total Submissions: 28748 My SubmissionsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you shoul原创 2014-03-14 17:36:25 · 1035 阅读 · 3 评论 -
【LeetCode】Remove Nth Node From End of List && 【九度】题目1517:链表中倒数第k个结点
Remove Nth Node From End of ListTotal Accepted: 8400 Total Submissions: 28316Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1-原创 2014-03-07 10:55:46 · 1122 阅读 · 0 评论 -
【LeetCode】Populating Next Right Pointers in Each Node I & II
Populating Next Right Pointers in Each Node Total Accepted: 6122 Total Submissions: 17900 My SubmissionsGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode原创 2014-01-16 13:24:35 · 938 阅读 · 0 评论 -
【LeetCode】Remove Duplicates from Sorted List I && II
I、每个数据只允许出现1次Remove Duplicates from Sorted List Total Accepted: 7120 Total Submissions: 20880 My SubmissionsGiven a sorted linked list, delete all duplicates such that each element appear only onc原创 2014-01-22 16:26:04 · 868 阅读 · 0 评论 -
【九度】题目1511:从尾到头打印链表
题目描述:输入一个链表,从尾到头打印链表每个节点的值。输入:每个输入文件仅包含一组测试样例。每一组测试案例包含多行,每行一个大于0的整数,代表一个链表的节点。第一行是链表第一个节点的值,依次类推。当输入到-1时代表链表输入完毕。-1本身不属于链表。输出:对应每个测试案例,以从尾到头的顺序输出链表每个节点的值,每个值占一行。原创 2013-12-13 15:50:36 · 967 阅读 · 0 评论 -
【LeetCode】234 Palindrome Linked List
Palindrome Linked ListTotal Accepted: 1116 Total Submissions: 4295 My Submissions Question Solution Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n原创 2015-07-10 16:33:05 · 3633 阅读 · 0 评论