首页 > 其他 > 详细

LeetCode Implement strStr() 实现strstr()

时间:2015-04-15 00:35:44      阅读:337      评论:0      收藏:0      [点我收藏+]

 

如题

思路:暴力就行了。1ms的暴力!!!别的牛人写出来的,我学而抄之~

技术分享

 

技术分享
 1 int strStr(char* haystack, char* needle) {
 2         if (!haystack || !needle) return -1;
 3         for (int i = 0; ; ++i) {
 4             for (int j = 0; ; ++j) {
 5                 if (needle[j] == 0) return i;
 6                 if (haystack[i + j] == 0) return -1;
 7                 if (haystack[i + j] != needle[j]) break;
 8             }
 9         }
10 }
strStr()

 

LeetCode Implement strStr() 实现strstr()

原文:http://www.cnblogs.com/xcw0754/p/4427224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!