Just corner case..class Solution {public: ListNode *reverseBetween(ListNode *head, int m, int n) { if(m == n) return head; ListNode *...
分类:
其他好文 时间:
2014-07-31 09:34:05
阅读次数:
245
题目描述:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra spac...
分类:
其他好文 时间:
2014-07-30 17:18:44
阅读次数:
204
问题描述:
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 the original relative order of the nodes in ...
分类:
其他好文 时间:
2014-07-30 12:21:33
阅读次数:
192
问题描述:
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 of the list.
解题思路:
将1->2->3->4->NUL...
分类:
其他好文 时间:
2014-07-30 10:07:54
阅读次数:
259
Convert Sorted List to Binary Search TreeTotal Accepted:12283Total Submissions:45910My SubmissionsGiven a singly linked list where elements are sorted...
分类:
其他好文 时间:
2014-07-29 17:29:32
阅读次数:
216
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2014-07-29 14:07:58
阅读次数:
163
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意:给定一个有序的链表,将其转换成平衡二叉搜索树思路: 二分法要构建一个平衡二叉...
分类:
其他好文 时间:
2014-07-29 13:40:48
阅读次数:
601
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...
分类:
其他好文 时间:
2014-07-29 11:29:56
阅读次数:
256
Sort a linked list using insertion sort.题目要求:链表的插入排序,由于没有时间复杂度的要求,可以直接循环操作。/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:
其他好文 时间:
2014-07-29 10:54:26
阅读次数:
190
解法:比较简单,用plus表示进位 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(in...
分类:
其他好文 时间:
2014-07-29 10:53:06
阅读次数:
273