//1.strcpy(拷贝)
char*my_strcpy(char*dst,constchar*src)
{
assert(dst);
assert(src);
char*cp=dst;
while(*cp++=*src++)
{
;
}
returndst;
}
//2.strcat(连接)
char*my_strcat(char*dst,constchar*src)
{
assert(dst);
assert(src);
char*cp=dst;
while(*cp!=‘\0‘)
{
cp+..
分类:
其他好文 时间:
2016-05-24 17:07:59
阅读次数:
128
1、前言: leetcode上的28. Implement strStr()就是一个字符串匹配问题。字符串匹配是计算机的基本任务之一。所以接下来的两篇日志,都对相关的算法进行总结。 2、暴力求解算法 如果用暴力匹配的思路,并假设现在文本串S匹配到 i 位置,模式串P匹配到 j 位置,则有: 如果当前 ...
分类:
编程语言 时间:
2016-05-23 19:00:29
阅读次数:
213
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib ...
分类:
其他好文 时间:
2016-05-23 18:44:08
阅读次数:
192
字符串的匹配,返回匹配开始的位置,直接用暴力方式求解。为了更快的匹配,定义一个指针表示待匹配的字符串的长度,当长度不足时,可 直接停止匹配。 char *strStr(char *haystack, char*needle) { char* p1; char* p2; char* p1_advanc ...
分类:
其他好文 时间:
2016-05-23 13:16:43
阅读次数:
85
Implement Stack using Queues
Total Accepted: 39756 Total
Submissions: 130128 Difficulty: Easy
Implement the following operations of a stack using queues.
push(x) -- Push e...
分类:
其他好文 时间:
2016-05-22 12:14:21
阅读次数:
145
Implement Queue using Stacks
Total Accepted: 44005 Total
Submissions: 129236 Difficulty: Easy
Implement the following operations of a queue using stacks.
push(x) -- Push e...
分类:
其他好文 时间:
2016-05-22 11:03:52
阅读次数:
125
Reverse Linked List Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? ...
分类:
其他好文 时间:
2016-05-20 13:26:09
阅读次数:
189
Implement a simple twitter. Support the following method: postTweet(user_id, tweet_text). Post a tweet.getTimeline(user_id). Get the given user's most ...
分类:
其他好文 时间:
2016-05-19 07:53:29
阅读次数:
390