1 package leetcode; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 class TrieNode{ 7 Boolean isWord;//true if path till ...
分类:
其他好文 时间:
2015-03-30 08:03:13
阅读次数:
252
这道题估计数据比较水,爆搜就能过
从这道题了解到strstr在随机数据的时候比kmp快。。。。正所谓KMP是一种很好的思想,但不实用
接下来就是了解了一些c里的库函数,一开始找不到求子串的函数,写完后才找到strncpy这个函数可以求子串
还有一点要注意的就是得到第一个结果的时候本来可以直接跳出的,但直接跳出的时候可能会碰到一些特殊数据,所以还是用个max记录最大的长度吧。。(这里WA了好多...
分类:
其他好文 时间:
2015-03-29 12:16:26
阅读次数:
90
题目:
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and...
分类:
其他好文 时间:
2015-03-29 00:38:50
阅读次数:
201
Let's make some fun to simulation Server - Client.1. socketI implement a echo server and use telnet to simulate the socket client.in this way, we don'...
分类:
Web程序 时间:
2015-03-21 15:25:51
阅读次数:
149
Implement pow(x,n).注意n等于INT_MIN的时候,直接让n = -n会整形溢出. 1 class Solution { 2 public: 3 double pow(double x, int n) { 4 if (n == 0) return 1; 5 ...
分类:
其他好文 时间:
2015-03-21 13:57:22
阅读次数:
130
Brute Force: 1 class Solution { 2 public: 3 int strStr(char *haystack, char *needle) { 4 if (!haystack) return -1; 5 if (!needle) ...
分类:
其他好文 时间:
2015-03-20 01:13:34
阅读次数:
110
题目链接:Sqrt(x)
Implement int sqrt(int x).
Compute and return the square root of x.
这道题的要求是实现int sqrt(int x),即计算x的平方根。
考虑二分,即先令l和r分别为1和x/2+1(x的平方根一定小于等于x/2+1),然后m等于(l+r)/2,不断比较m*m和x的大小。
由于...
分类:
其他好文 时间:
2015-03-20 00:07:04
阅读次数:
166
Implement int sqrt(int x). 这道题本质上是求sqrt(x)下最大的整数。二分查找是比较容易想到的方法。另,在网上又学习了下别人的牛顿迭代法。 这是我原来的写法,写入是错误的,复杂度太高 class Solution {
public: int sqrt(int x) { i...
分类:
移动开发 时间:
2015-03-19 13:01:00
阅读次数:
148
成员变量的作用域public:在任何地方都能直接访问对象的成员变量private:只能在当前类的对象方法中直接访问(@implement中默认的)protected:可以在当前类及其子类的对象方法中直接访问(@interface中默认的)package:只要处在同一框架中,就能直接访问对象的成员变量...
分类:
其他好文 时间:
2015-03-18 17:45:33
阅读次数:
108