包含文件:string.h函数名: strstr函数原型:extern char
*strstr(const char *str1, const char *str2);语法:* strstr(str1,str2)str1:
被查找目标 string expression to search.str...
分类:
其他好文 时间:
2014-05-24 06:31:32
阅读次数:
230
【题目】
原文:
2.2 Implement an algorithm to find the nth to last element of a singly linked list.
译文:
实现一个算法从一个单链表中返回倒数第n个元素。
【分析】
【思路一】
(1)创建两个指针p1和p2,指向单链表的开始节点。
(2)使p2移动n-1个位置,使之指向从头...
分类:
其他好文 时间:
2014-05-22 09:03:53
阅读次数:
315
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:
get and set.
get(key) - Get the value (will always be positive) of the key if t...
分类:
其他好文 时间:
2014-05-22 07:25:32
阅读次数:
254
【题目】
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replac...
分类:
其他好文 时间:
2014-05-18 09:54:53
阅读次数:
242
【题目】
Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
【题意】
实现库函数strStr(), 功能是在字符串haystack中找出目标串needle第一次出现的索引位
【思路】
字符串的匹配,可以用暴力解法,但不推荐。一般使用KMP算法求解。
简要介绍一下KMP的思想:
...
分类:
其他好文 时间:
2014-05-18 04:10:04
阅读次数:
244
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 input cases.
Notes: It is intended for this problem to be specifi...
分类:
其他好文 时间:
2014-05-15 05:00:50
阅读次数:
229
Call back function easily implement
#include
void HelloWorld(int nIndex)
{
printf("%d person say Hello World\n",nIndex);
}
void MyName(int len)
{
printf...
分类:
其他好文 时间:
2014-05-15 04:21:05
阅读次数:
270
Implement strStr().Returns a pointer to the
first occurrence of needle in haystack, or null if needle is not part of
haystack.此题我觉得并不是真要你写出kmp算法。 指针暴力...
分类:
其他好文 时间:
2014-05-15 01:49:42
阅读次数:
330
【题目】
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype shoul...
分类:
其他好文 时间:
2014-05-14 21:36:52
阅读次数:
348
【题目】
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 input cases.
Notes: It is intended for this problem to be s...
分类:
其他好文 时间:
2014-05-14 21:00:57
阅读次数:
304