Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?...
分类:
其他好文 时间:
2015-03-12 22:35:49
阅读次数:
164
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-03-12 20:48:41
阅读次数:
114
Sort List问题:Sort a linked list inO(nlogn) time using constant space complexity.思路: 归并排序我的代码:public class Solution { public ListNode sortList(ListN...
分类:
其他好文 时间:
2015-03-11 21:30:59
阅读次数:
165
题目要求: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 shoul...
分类:
其他好文 时间:
2015-03-11 21:30:30
阅读次数:
123
Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort...
分类:
其他好文 时间:
2015-03-11 19:18:11
阅读次数:
108
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="ADOBECODEBA...
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="ADOBECODEBA...
EvolutionTime Limit:5 Seconds Memory Limit:32768 KBDescriptionEvolution is a long, long process with extreme complexity and involves many species. Dr....
分类:
其他好文 时间:
2015-03-10 21:06:23
阅读次数:
218
Sort a linked list in O(n log n) time using constant space complexity.这题的时间复杂度要求是O(n logn),很容易想到用mergeSort来解。/** * Definition for singly-linked list. ...
分类:
其他好文 时间:
2015-03-09 23:54:04
阅读次数:
212
题目:
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
思路:
解法一:维护一个大小为k的堆,每次去堆顶的最小元素放到结果中,然后读取该元素的下一个元素放入堆中,重新维护好。因为每个链表是有序的,每次又是去当前k个元素中最小的,...
分类:
其他好文 时间:
2015-03-09 22:32:10
阅读次数:
203