码迷,mamicode.com
首页 >  
搜索关键字:implement strstr    ( 2381个结果
leetcode_Implement Queue using Stacks
1.用栈来实现一个队列,也就是用后进先出的栈实现先进先出的队列 2.这个还是很难想的,但总之还是比用队列来实现栈容易想,大概就是用两个栈stack1和stack2来模拟队列 3.所有的元素都从stack1进栈,所有元素都从stack2出栈,当stack2为空的时候,将stack1中的所有元素出栈并全部push到stack2中去 4.由于栈是后进先出的,两次后进先出的操作就实现了队列的功能...
分类:其他好文   时间:2015-08-07 09:36:18    阅读次数:118
leetcode_Sqrt(x)
描述: Implement int sqrt(int x). Compute and return the square root of x. 思路: 按题意来说是实现一个api方法,对整数开根号 1.用二分的方法来对一个整数开根号,每次循环求start和end之间的值mid来计算,若mid*mid>x,则end变为mid,若mid*mid 2.对于1中的思路有两个不足的地方,假如...
分类:其他好文   时间:2015-08-06 22:31:07    阅读次数:159
返回主串中子串及其后的所有字符
题目:           写一个函数模拟c++中的strstr函数。该函数的返回值是主串中字符子串的位置以后的所有字符。请不要使用任何c程序已有的函数来完成。 #include using namespace std; const char* strstr1(const char* string, const char* strCharSet) { for (int i = ...
分类:其他好文   时间:2015-08-06 22:23:12    阅读次数:218
【leetcode】232. Implement Queue using Stacks
leetcode, 使用栈来模拟队列...
分类:其他好文   时间:2015-08-06 20:31:57    阅读次数:107
php中经常使用的string函数
strpos() ---返回字符串在另一字符串中首次出现的位置strrpos() ---查找字符串在另一字符串中最后出现的位置strchr() === strstr()strrchr()strtr() ---替换字符(容易混乱strstr())str_replace()strlen()mb_...
分类:Web程序   时间:2015-08-06 20:08:13    阅读次数:146
Hdu 5311 Hidden String
一道查找字符串的题,要求在给出的字符串中找出三段字符串a,b,c,其中a,b,c三个字符串有先后关系,且不能有交集,即原字符串中的一个字母不能被用两次。 这三个字符串拼成“anniversary”。 先后A了两次,第一次用头文件中的strncpy和strstr函数。我再昨天也写了一篇随笔...
分类:其他好文   时间:2015-08-05 21:55:11    阅读次数:115
[leedcode 208] Implement Trie (Prefix Tree)
Trie树又被称为字典树、前缀树,是一种用于快速检索的多叉树。Tried树可以利用字符串的公共前缀来节省存储空间。但如果系统存在大量没有公共前缀的字符串,相应的Trie树将非常消耗内存。(下图为Wiki上的Trie树示意图, https://en.wikipedia.org/wiki/Trie)子节...
分类:其他好文   时间:2015-08-05 00:38:20    阅读次数:165
LeetCode#50 Pow(x, n)
Just...Implement pow(x, n).Solution:1)Naive solution:multiply x by itself for n-1 times. (Or simply reyurn 1 if n==0).This takes O(n) time. When n is ...
分类:其他好文   时间:2015-08-04 22:43:29    阅读次数:132
C/C++用strncpy()与strstr()分割与匹配查找字符串
最近做题遇到分割与匹配字符串的题目(hdu5311),看来别人的代码,才知道有strncpy()和strstr()函数,于是搜集了一点资料,记录一下基本用法。一、strncpy()char * strncpy ( char * destination, const char * source, si...
分类:编程语言   时间:2015-08-04 18:52:01    阅读次数:141
(leetcode)Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()...
分类:其他好文   时间:2015-08-04 15:34:50    阅读次数:96
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!