Follow up for "Find Minimum in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Suppose a sorted array is rotated at some pivot unkno...
分类:
其他好文 时间:
2014-10-22 12:56:43
阅读次数:
223
Sort a linked list in O(n log n) time using constant space complexity.
思路:要想时间复杂度达到O(n log n)
,那么有两种,一种是合并排序,另一种是快速排序,而要想空间复杂度为常数,那么只能使用递归,本人使用的是递归的合并排序,代码如下:
/**
* Definition for s...
分类:
其他好文 时间:
2014-10-22 12:55:55
阅读次数:
200
Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity...
分类:
编程语言 时间:
2014-10-21 22:53:06
阅读次数:
316
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a...
分类:
其他好文 时间:
2014-10-21 17:25:09
阅读次数:
185
Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort...
分类:
编程语言 时间:
2014-10-21 17:04:11
阅读次数:
226
problem:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.先合并两个list,再根据归并排序的方法递归合并。假设总共有k个list,每个list的最大...
分类:
其他好文 时间:
2014-10-20 02:00:03
阅读次数:
197
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-10-19 18:18:19
阅读次数:
188
Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity...
分类:
其他好文 时间:
2014-10-16 05:43:32
阅读次数:
160
Problem's Link:http://acm.nyist.net/JudgeOnline/problem.php?pid=514Mean:给你一个l和r,求出在这个范围内的1的个数。analyse:简单的数位推理。Time complexity:O(n) n为数字的位数Source code:...
分类:
其他好文 时间:
2014-10-13 18:36:56
阅读次数:
146
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...
分类:
其他好文 时间:
2014-10-12 16:06:48
阅读次数:
185