题目链接:Search for a Range
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...
分类:
其他好文 时间:
2015-02-04 23:24:39
阅读次数:
254
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BANC"...
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BAN...
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
一开始我没有采用分治法,解题思路是:首先比较每条链表的第一个元素,找出最小的那个,插入新链表并从原链表删除,如此反复直至所有的链表都为空链表。基于这个愚蠢的解题思路,我的C++代码实现如下:
...
分类:
其他好文 时间:
2015-02-03 17:19:27
阅读次数:
158
Given an integer?n, return the number of trailing zeroes in?n!. Note:?Your solution should be in logarithmic time complexity. Credits: Special thanks to?@ts ?for adding this problem and creat...
分类:
其他好文 时间:
2015-02-03 11:23:32
阅读次数:
125
1. Counting Sort doesn't work for negative number.2. Counting Sort assumes that each element is SMALL INTEGER.3. Time Complexity is O(Maximum value - ...
分类:
其他好文 时间:
2015-02-03 01:53:09
阅读次数:
130
Given an array of integers, every element appears three timesexcept for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement itwithout using e...
分类:
编程语言 时间:
2015-02-02 23:15:12
阅读次数:
248
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...
分类:
其他好文 时间:
2015-02-02 22:58:13
阅读次数:
280
题目:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a s...
分类:
编程语言 时间:
2015-01-31 16:09:35
阅读次数:
170
题目链接:Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
这道题的要求是将k个有序链表合并成1个有序链表,并分析其复杂度。
1. 暴力合并
最简单思路就是暴力合并,可以将k个链表一个接着一个地合并...
分类:
其他好文 时间:
2015-01-31 14:42:33
阅读次数:
163