转自: http://www.infoq.com/cn/articles/etcd-interpretation-application-scenario-implement-principleetcd:从应用场景到实现原理的全方位解读随 着CoreOS和Kubernetes等项目在开源社区日益火热...
分类:
其他好文 时间:
2015-11-10 10:30:44
阅读次数:
342
char*my_strstr(char*str1,char*str2){assert(str1);assert(str2);char*p=str1;char*pstr1=p;char*pstr2=NULL;while(*pstr1){pstr1=p;pstr2=str2;while(*pstr1&&*pstr2&&*pstr1==*pstr2){pstr1++;pstr2++;}if(*pstr2==‘\0‘){returnp;}p++;}returnNULL;}
分类:
其他好文 时间:
2015-11-10 01:52:03
阅读次数:
186
思路:1.找出n个字符串中最短的字符串Str[N]2.从长到短找Str[N]的子子串 subStr[N],以及subStr[N]的反转字符串strrev(subStr[N]);(从长到短是做剪枝处理)3.用strstr()函数遍历所有的字符串,看是否含有此子子串subStr[N]或strrev(su...
分类:
其他好文 时间:
2015-11-09 22:26:51
阅读次数:
187
Implement a trie withinsert,search, andstartsWithmethods.Note:You may assume that all inputs are consist of lowercase lettersa-z.思路:应该就是字典树。 1 class T...
分类:
其他好文 时间:
2015-11-09 08:17:46
阅读次数:
205
★创建一个函数,实现库函数strstr的功能
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
char*my_strstr(char*src,char*dst)
{
assert(dst);
assert(src);
char*p=src;
char*q=dst;
while((*dst)&&(*src))
{
if(*src==*dst)//两指针内..
分类:
其他好文 时间:
2015-11-09 00:15:24
阅读次数:
263
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 using ex...
分类:
其他好文 时间:
2015-11-08 15:21:37
阅读次数:
195
Given an array of integers, every element appears twice except for one. Find that single one.Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra me...
分类:
其他好文 时间:
2015-11-08 15:20:47
阅读次数:
176
原题链接在这里:https://leetcode.com/problems/word-search-ii/是Word Search的进阶版题目,同时可以利用Implement Trie (Prefix Tree).生成Trie树,把所有的词都insert进去。然后用递归回朔来查,若是没有prefix...
分类:
其他好文 时间:
2015-11-07 10:49:27
阅读次数:
195
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation – it essentially peek() at the element that will be return...
分类:
其他好文 时间:
2015-11-06 21:04:05
阅读次数:
276
题目Implement TrieImplement a trie with insert, search, and startsWith methods.样例注意You may assume that all inputs are consist of lowercase letters a-z.解...
分类:
其他好文 时间:
2015-11-06 20:47:13
阅读次数:
267