Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.思路:这是一道字符串匹配的函数,就是找出needle...
分类:
其他好文 时间:
2014-06-18 22:16:17
阅读次数:
236
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 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 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
题目
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
题目
Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
方法
只需要遍历一遍即可。
public String strStr(String...
分类:
其他好文 时间:
2014-06-16 19:07:08
阅读次数:
188
既然“指针”的使用者一不小心就可能导致内存泄漏,那么我们如何能够使得指针的使用变得更安全呢?从C++面向对象的角度分析,我们有没有可能将“指针”封装起来,使得用户不直接接触指针,而使用一个封装后的对象来替代指针的操作呢?
答案是显然的,“智能指针”(smart pointer)正解决这类问题,尤其是在防止内存泄漏方面做得非常突出。C++标准库std中提供了一种“智能指针类”名为"...
分类:
编程语言 时间:
2014-06-15 15:04:11
阅读次数:
352
题目
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],...
分类:
其他好文 时间:
2014-06-15 14:10:54
阅读次数:
239
Problem Description
In a factory, there are N workers to finish two types of tasks (A and B). Each type has N tasks. Each task of type A needs xi time to finish, and each task of type B needs yj ti...
分类:
其他好文 时间:
2014-06-15 11:26:42
阅读次数:
195