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
原题地址:https://oj.leetcode.com/problems/insert-interval/题意:Given
a set ofnon-overlappingintervals, insert a new interval into the intervals
(merge if ne...
分类:
编程语言 时间:
2014-06-12 16:13:09
阅读次数:
350
原题地址:https://oj.leetcode.com/problems/merge-intervals/题意:Given
a collection of intervals, merge all overlapping intervals.For
example,Given[1,3],[2,6]...
分类:
编程语言 时间:
2014-06-12 14:55:49
阅读次数:
235
题目:
Given two sorted integer arrays A and B, merge B into A as one sorted array.
原题链接(点我)
解题思路:
合并两个数组为一个有序数组,这题也很简单,唯一考查的地方就是怎么处理数组,是从前往后还是从后往前。一般情况,从后往前的效率比从前往后高,也要省不少事。代码如下,从后开始合并。
代码实现:...
分类:
其他好文 时间:
2014-06-11 00:37:42
阅读次数:
314
Given two sorted integer arrays A and B, merge
B into A as one sorted array.Note:You may assume that A has enough space (size
that is greater or equal...
分类:
其他好文 时间:
2014-06-10 20:44:02
阅读次数:
298
Question: Mergeksorted linked lists and return
it as one sorted list. Analyze and describe its complexity.Solution: Find the
smallest list-head first....
分类:
其他好文 时间:
2014-06-10 19:51:30
阅读次数:
278
题目
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.
方法
有序链表,合并成一个有序链表。
public ListNod...
分类:
其他好文 时间:
2014-06-10 18:13:11
阅读次数:
241