题目
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target i...
分类:
其他好文 时间:
2014-06-15 16:53:32
阅读次数:
177
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
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
The most strait forward approach is calculating
all the possible areas and keep the max one as the result. This approach needs
O(n*n) time complexity,...
分类:
其他好文 时间:
2014-06-10 16:11:31
阅读次数:
184
Sort a linked list inO(nlogn) time using
constant space complexity.单向链表排序O(nlogn),Mergesort可以实现。 1 /** 2 * Definition for
singly-linked list. 3 * st.....
分类:
其他好文 时间:
2014-06-10 00:44:11
阅读次数:
329
Sort a linked list in O(n log n) time using
constant space
complexity.一谈到时间复杂度O(nlogn),立即联想到以下3种排序方法:1.归并排序(基于分治):时间复杂度O(nlogn),归并排序的最好、平均、最坏时间复杂度没有差别...
分类:
其他好文 时间:
2014-06-09 20:37:31
阅读次数:
244
Follow up for "Search in Rotated Sorted
Array":What ifduplicatesare allowed?Would this affect the run-time complexity?
How and why?Write a function to...
分类:
其他好文 时间:
2014-06-08 01:19:29
阅读次数:
320
1. 普通的二分查找2. 查找最左边的值3. 查找最右边的值Worst case
performance: O(log n)Best case performance: O(1)Average case performance: O(log
n)Worst case space complexity...
分类:
其他好文 时间:
2014-06-07 11:19:48
阅读次数:
248
Sort a linked list inO(nlogn) time using
constant space complexity./** * Definition for singly-linked list. * struct
ListNode { * int val; * L...
分类:
其他好文 时间:
2014-06-06 20:01:30
阅读次数:
333