Description :Given a singly linked list where
elements are sorted in ascending order, convert it to a height balanced
BST.分析:这道题目简单版是把一个排序好的数组转成平衡的二叉树...
分类:
其他好文 时间:
2014-06-16 10:51:54
阅读次数:
237
原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/题意:Given
a sorted linked list, delete all nodes that have duplicate number...
分类:
编程语言 时间:
2014-06-16 10:40:35
阅读次数:
340
Question:Sort a linked list inO(nlogn) time
using constant space complexity.Solution:Merge sort.找到链表的中间的那个ListNode. 1 /** 2
* Definition for singly-l....
分类:
其他好文 时间:
2014-06-12 17:59:34
阅读次数:
285
Reverse Linked List IIReverse a linked list from
positionmton. Do it in-place and in one-pass.For example:Given
1->2->3->4->5->NULL, m= 2 andn= 4,retu...
分类:
其他好文 时间:
2014-06-12 07:03:54
阅读次数:
308
Partition ListGiven a linked list and a valuex,
partition it such that all nodes less thanxcome before nodes greater than or
equal tox.You should pres...
分类:
其他好文 时间:
2014-06-12 06:18:55
阅读次数:
562
问题:
给定个单链表,判断该链表是否存在环。
分析:
这个问题是见的非常多的题目,问题本身而言,技巧性很强,或者说思路很巧妙,这里要说的不是这个题目本身,而是说这种技巧,在很多的地方是用的到的,比如,在寻找单链表的中间节点的时候,就可以用这种形式,一个走两步,一个走一步的形式,来获得中间节点。
//
bool hasCycle(ListNode *head) {
if(...
分类:
其他好文 时间:
2014-06-10 10:48:49
阅读次数:
176