码迷,mamicode.com
首页 >  
搜索关键字:implement strstr    ( 2381个结果
Implement Stack using Queues
这题是使用队列去实现栈,属于比较基础的题目。需要考虑的点在于队列为先进先出,即入队在队尾,但是出队在队首,而栈为先进后出,即出栈和入栈都在栈尾。需要实现的功能如下: push(x) -- Push element x onto stack. pop() -- Removes the element ...
分类:其他好文   时间:2016-04-10 01:09:43    阅读次数:174
在一个字符串中查找还有一个字符串出现的次数
#include<stdio.h> #include <string.h> int strstrcount( char *str1, char *str2 ) { char *str = str1; int c = 0; while( (str = strstr( str, str2 )) != N ...
分类:其他好文   时间:2016-04-09 17:01:32    阅读次数:142
模拟实现strstr函数。
//1.模拟实现strstr函数。 #include<stdio.h> #include<assert.h> char*my_strstr(char*str,char*p) { char*cp=p; char*p1=str; assert(*p); if(!*p) returnNULL; if(!*p1) returnNULL; char*p2=str; while(*p1) { p2=p1; cp=p; while(*p2&&*cp&&!..
分类:其他好文   时间:2016-04-08 15:26:59    阅读次数:114
[LeetCode] Flatten Nested List Iterator 压平嵌套链表迭代器
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-04-06 13:31:49    阅读次数:354
zoj 1061 Web Navigation
Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use tw ...
分类:Web程序   时间:2016-04-06 02:04:48    阅读次数:211
lintcode-medium-Segment Tree Modify
For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in this node's interval. Implement a modify function wit ...
分类:其他好文   时间:2016-04-05 19:19:49    阅读次数:135
LeetCode 225. Implement Stack using Queues
用queue模拟stack,因为queue只能取front的值,和stack正好相反,因此核心思想是queue保持着与stack相反的顺序,一直逆序,所以每次push进一个新值后,要依次把新值之前的值排到队尾。比如原来q为4、5,push进1,q依次为:4、5、1;5、1、4;1、4、5. 对应的s ...
分类:其他好文   时间:2016-04-04 21:00:17    阅读次数:165
LeetCode 232. Implement Queue using Stacks
和225类似,queue和stack的性质正好相反,因此在push时要进行处理。 维护两个stack:stk和tmp,stk存放与queue相反的顺序,比如queue为:1、4、5,stk为:5、4、1,这样stk.top()会一直等于queue.front()。 每次push进一个数x时,先把st ...
分类:其他好文   时间:2016-04-04 20:55:45    阅读次数:232
lintcode-medium-Pow(x, n)
Implement pow(x, n). Notice You don't need to care about the precision of your answer, it's acceptable if the expected answer and your answer 's diffe ...
分类:其他好文   时间:2016-04-04 16:09:48    阅读次数:122
[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( ...
分类:其他好文   时间:2016-04-02 17:32:59    阅读次数:214
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!