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 ...
分类:
其他好文 时间:
2016-04-08 13:14:51
阅读次数:
122
这一章比较短! 空间复杂度(space complexity)和辅助空间(auxiliary space)经常混用,下面是正确的辅助空间和空间复杂度的定义 辅助空间:算法需要用到的额外或者暂时的存储空间。 空间复杂度:是指算法所需要的所有存储空间,这是跟输入数据的大小决定的。空间复杂度包括辅助空间和 ...
分类:
其他好文 时间:
2016-04-07 07:07:33
阅读次数:
118
Sort a linked list in O(n log n) time using constant space complexity. Example Given 1-3->2->null, sort it to 1->2->3->null. /** * Definition for List ...
分类:
其他好文 时间:
2016-04-06 08:12:15
阅读次数:
114
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh ...
分类:
其他好文 时间:
2016-04-06 07:05:34
阅读次数:
239
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 functio ...
分类:
其他好文 时间:
2016-04-05 19:16:24
阅读次数:
124
Round House
题目链接:
http://codeforces.com/problemset/problem/659/A
解题思路:
The answer for the problem is calculated with a formula ((a?-?1?+?b) n + n) n + 1.
Such solution has complexity...
分类:
其他好文 时间:
2016-04-01 10:18:00
阅读次数:
242
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example Given lists: [ 2->4->null, null, -1->null ] ...
分类:
其他好文 时间:
2016-03-31 09:31:51
阅读次数:
169
问题描述:Sort a linked list in O(n log n) time using constant space complexity. O(n lgn)时间复杂度,O(1)空间复杂度。 分析:O(n lgn)时间复杂度的排序算法有几个(快排,归并,希尔,堆),但是O(1)空间复杂度就 ...
分类:
其他好文 时间:
2016-03-29 14:18:49
阅读次数:
134
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 or ...
分类:
其他好文 时间:
2016-03-28 15:00:51
阅读次数:
144