LeetCode 28. Implement strStr()
2016-11-17 12:46
369 查看
描述
实现strStr()函数解决
遍历class Solution { public: int strStr(string haystack, string needle) { int length2 = needle.size(); int length1 = haystack.size(); if (length1 == 0 && length2 == 0) return 0; for (int i = 0; i + length2 - 1< length1; ++i) { if (haystack.substr(i, length2) == needle) return i; } return -1; } };
相关文章推荐
- Leetcode题解 28. Implement strStr()
- (Java)LeetCode-28. Implement strStr()
- leetcode 28. Implement strStr()
- leetcode 28. Implement strStr()
- leetcode28. Implement strStr()
- 【leetcode】28. Implement strStr()
- 个人记录-LeetCode 28. Implement strStr()
- LeetCode 28. Implement strStr()
- [leetcode]#28. Implement strStr()
- [leetcode]28. Implement strStr()
- [LeetCode] 28. Implement strStr()
- leetcode:28. Implement strStr()
- 【一天一道LeetCode】#28. Implement strStr()
- LeetCode 28. Implement strStr()
- Leetcode28. Implement strStr()
- [LeetCode]28. Implement strStr()
- Leetcode 28. Implement strStr()
- leetcode 28. Implement strStr()
- [leetcode] 28. Implement strStr()
- LeetCode28. Implement strStr()