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
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2014-06-18 12:32:58
阅读次数:
169
题目
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the...
分类:
其他好文 时间:
2014-06-18 12:05:44
阅读次数:
244
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]...
分类:
其他好文 时间:
2014-06-18 11:41:52
阅读次数:
156
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to
m + n) to
hold additional ele...
分类:
其他好文 时间:
2014-06-17 23:05:13
阅读次数:
246
Given n non-negative integers a1, a2,
..., an, where each represents a point at coordinate (i, ai). n vertical
lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
0). Fin...
分类:
其他好文 时间:
2014-06-17 22:17:43
阅读次数:
325
Given two words word1 and word2, find the minimum number of steps required to convert
word1 to word2. (each operation is counted as 1 step.)
You have the following 3 operations permitted...
分类:
其他好文 时间:
2014-06-17 21:43:38
阅读次数:
219
题目
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
题目
Divide two integers without using multiplication, division and mod operator.
方法
将除数倍加,直到大于被除数。
public int divide(int dividend, int divisor) {
int flag = 0;
if...
分类:
其他好文 时间:
2014-06-16 19:08:08
阅读次数:
200