1. 问题描述 Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Tags:Two Pointers ...
分类:
其他好文 时间:
2016-08-07 00:49:04
阅读次数:
125
WildcardMatching:通配符匹配 算法分析: 1. 二个指针i, j分别指向字符串、匹配公式。 2. 如果匹配,直接2个指针一起前进。 3. 如果匹配公式是*,在字符串中依次匹配即可。 注意记录上一次开始比较的位置 Implement wildcard pattern matching ...
分类:
其他好文 时间:
2016-08-06 19:12:33
阅读次数:
159
Implement strstr() 实现strstr函数功能 whowhoha@outlook.com Question: Implement strstr(). Returns the index of the first occurrence of needle in haystack, or ...
分类:
其他好文 时间:
2016-08-06 09:58:19
阅读次数:
132
Question: Design and implement a TwoSum class. It should support the following operations: add and find. add(input) – Add the number input to an inter ...
分类:
其他好文 时间:
2016-08-06 09:50:28
阅读次数:
196
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek()operation -- it es ...
分类:
其他好文 时间:
2016-08-06 09:40:50
阅读次数:
140
Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: By calling next repeatedly until ...
分类:
其他好文 时间:
2016-08-06 07:01:09
阅读次数:
121
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 分析: 给出两个字符串,查询第二个字符串是否在第 ...
分类:
其他好文 时间:
2016-08-05 19:49:31
阅读次数:
164
Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ ...
分类:
其他好文 时间:
2016-08-05 13:52:42
阅读次数:
92
Question:
Implement int sqrt(int x).
Compute and return the square root of x.
求平方根
Algorithm:
牛顿迭代法,迭代多次后,可以求出平方根。
还有一种雷神之锤3的程序代码,比C++标准库sqrt()的还快。
在这里贴出链接:点击打开链接 ,如果有大神看懂了麻烦讲...
分类:
其他好文 时间:
2016-08-04 11:42:28
阅读次数:
165
题意: Implement atoi to convert a string to an integer. 分析: 就是注意各种特殊情况,边界情况的判断,见代码注释。 ...
分类:
其他好文 时间:
2016-08-03 23:39:44
阅读次数:
180