Very similar as "Implement Stack using Queues".class Queue { stack _s0; stack _s1; int _front; public: // Push element x to the back of...
分类:
其他好文 时间:
2015-07-07 07:03:55
阅读次数:
112
题目:
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible...
分类:
编程语言 时间:
2015-07-06 14:19:22
阅读次数:
145
Implement strStr() : https://leetcode.com/problems/implement-strstr/Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
如:haystack = “bcbcda”; nee...
分类:
其他好文 时间:
2015-07-05 16:48:14
阅读次数:
342
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() -- Get the top element.
empty() -- Retur...
分类:
其他好文 时间:
2015-07-05 16:44:56
阅读次数:
148
#include
#include
int strstrcount( char *str1, char *str2 )
{
char *str = str1;
int c = 0;
while( (str = strstr( str, str2 )) != NULL )
{
c++;
str++;
}
return c;
}
int main()
{...
分类:
其他好文 时间:
2015-07-04 21:04:33
阅读次数:
131
// 模拟库函数strstr
#include
#include
const char* my_strstr(const char *parent, const char *child)
{
const char *pgo = parent;
const char *cgo = child;
const char *pgos = parent;
assert(parent != ...
分类:
编程语言 时间:
2015-07-04 12:43:16
阅读次数:
216
//判断一个字符串是否是一个字符串的旋转字符串
//利用库函数实现
#include
#include
#include
int IsRotate(char *str1, const char *str2)
{
assert(str1);
assert(str2);
strncat(str1, str1,strlen(str1));
if (NULL == strstr(str1, ...
分类:
编程语言 时间:
2015-07-04 11:20:31
阅读次数:
211
//模拟实现库函数strstr,查找子字符串
#include
#include
char * my_strstr( char *dst, const char * src)
{
assert(dst);
assert(src);
int i, j, k;
for (i = 0; dst[i] != '\0'; i++)
{
for (j = i, k = 0; src[k] !...
分类:
编程语言 时间:
2015-07-04 11:19:02
阅读次数:
174
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.在一个字符串中查找另外一个字符串是否存在。暴力 O(...
分类:
其他好文 时间:
2015-07-04 09:36:32
阅读次数:
110
称号Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.方法仅仅须要遍历一遍就可以。 publi...
分类:
其他好文 时间:
2015-07-03 20:28:49
阅读次数:
93