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 ord...
分类:
其他好文 时间:
2014-06-28 19:23:45
阅读次数:
200
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 is not found ...
分类:
其他好文 时间:
2014-06-22 21:47:15
阅读次数:
269
Sort a linked list in O(n log n)
time using constant space complexity.
这道题目非常简短的一句话,给链表排序,看到nlogn,我们可以来简单复习一下排序。首先说一下这个nlogn的时间复杂度(根据决策树我们可以得出这个界限),是基于比较排序的最小上限,也就是说,对于没有一定范围情况的数据来说,最快的排序思路就是归并和快速排...
分类:
其他好文 时间:
2014-06-22 09:02:54
阅读次数:
250
Virtualization Basics Virtualization is not a new concept, but its complexity has been growing, and a number of new paradigms are rising. I will try t...
分类:
其他好文 时间:
2014-06-21 18:08:03
阅读次数:
336
Sort a linked list inO(nlogn) time using constant space complexity.本题利用归并排序即可归并排序的核心是将两部分合成一部分,故开始要将链表分成两部分,利用快慢两个指针,当快指针跑到链表尾部时,慢指针恰好在中间,故可以将链表分成两部分然...
分类:
其他好文 时间:
2014-06-21 12:20:11
阅读次数:
188
Question:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity s...
分类:
其他好文 时间:
2014-06-21 08:34:52
阅读次数:
172
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-18 20:54:36
阅读次数:
202
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-06-18 17:39:11
阅读次数:
260
题目
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
方法
使用归并排序的思想,两两合并,直到最终变成一个。
public ListNode mergeKLists(ArrayList lists) {...
分类:
其他好文 时间:
2014-06-17 21:34:41
阅读次数:
183
题目
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Write a function to determine if a given target is in the array.
原题链接(点我)
解题思路
这题和Search in Rotated Sorted Array问题类似,...
分类:
其他好文 时间:
2014-06-14 12:44:18
阅读次数:
266