1.1 Implement an algorithm to determine if a string has all unique characters. Whatif you cannot use additional data structures? 1 #include 2 #includ....
分类:
其他好文 时间:
2014-08-09 18:17:58
阅读次数:
199
这道题第一眼看见题目所给的时间就有一种预感,仅仅是600ms,运行的算法复杂度稍微高一点就会超时。那么我首先是犯傻想偷偷懒,直接是调用一个系统库函数strstr(),希望它能够完成自己的题目,但是显然是超时的。百度了一下它的实现方法是直接采用没有优化的算法,复杂度是最高的。但是由于自己压根就不会写字...
分类:
其他好文 时间:
2014-08-09 18:15:38
阅读次数:
291
Problem Description:
Implement pow(x, n).
分析:题目意思很简单,要求计算x的n次幂,其中x给的是double类型,n需要考虑负数的情况,利用二分的思想每次将n减半,递归计算可以得到最终结果,其中一些细节需要注意,具体的实现代码如下:
class Solution {
public:
bool isequal(double a,doubl...
分类:
其他好文 时间:
2014-08-07 19:17:00
阅读次数:
179
题目:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.题解:其实我觉得这题。。为啥不给个更明确....
分类:
编程语言 时间:
2014-08-07 12:43:19
阅读次数:
227
题目: Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be....
分类:
编程语言 时间:
2014-08-07 12:08:49
阅读次数:
260
策略模式定义了一系列的算法,并将每一个算法封装起来,而且使它们还可以相互替换。而对于客户端(UI)来说,可以通过IOC再配合工厂模块,实现动态策略的切换,策略模块通常于一个抽象策略对象(interface or abstract class),多个具体策略对象(implement class )和一...
分类:
其他好文 时间:
2014-08-07 09:43:19
阅读次数:
159
题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding elem....
分类:
编程语言 时间:
2014-08-06 04:11:20
阅读次数:
429
题目:Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (includin....
分类:
编程语言 时间:
2014-08-06 04:10:50
阅读次数:
325
Problem Description:
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rea...
分类:
其他好文 时间:
2014-08-05 22:40:40
阅读次数:
241
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 u...
分类:
其他好文 时间:
2014-08-05 22:35:00
阅读次数:
277