[LintCode]strStr(C++)
来源:互联网 发布:米惠淘宝返利网 编辑:程序博客网 时间:2024/06/07 06:10
class Solution {public: /** * Returns a index to the first occurrence of target in source, * or -1 if target is not part of source. * @param source string to be scanned. * @param target string containing the sequence of characters to match. */ int strStr(const char *source, const char *target) { // write your code here int i = 0; int j = 0; if(source == NULL || target == NULL) return -1; int lens = strlen(source); int lent = strlen(target); for (i = 0; i < lens - lent + 1; i++) { for (j = 0; j < lent; j++) { if (source[i + j] != target[j]) { break; } } if (j == lent) { return i; } } return -1; }};
阅读全文
0 0
- [LintCode]strStr(C++)
- *[Lintcode]strStr
- [LintCode] 1. strStr
- lintcode之strStr
- strstr.c
- lintcode 字符串查找(strStr) (Java)
- c语言实现strstr
- 【C库函数】strstr实现
- strstr()函数-C语言
- C语言strstr
- C中strstr()
- C语言strstr函数
- C实现strstr函数
- 【C语言】 实现strstr
- C语言 函数 strstr
- C-strstr函数
- strstr ( )【C语言库函数源代码】
- strstr的c语言实现
- jquery中的attr()和prop()的区别
- PAT---1021. 个位数统计 (15)
- 1、在一个由自然数1-1000中某些数字所组成的数组中,每个数字可能出现零次或者多次。设计一个算法,找出出现次数最多的数字。
- 解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- (4)document:getElementById、getElementByName、getNodeByTagName
- [LintCode]strStr(C++)
- uva 400 Unix ls 127页
- stl容器
- HashMap重要知识点总结
- [LintCode]Anagrams(Python)
- 朴素贝叶斯原理及实现
- 关于一个图中是否存在负环
- python-pandas的基本用法03
- uva 136 120页