leetcode--28. Implement strStr()
2017-01-15 22:35
363 查看
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
题解
class Solution { public: int strStr(string haystack, string needle) { for(int i = 0; ; ++i){ for(int j = 0; ; ++j){ if(j == needle.length()) return i; if(i + j == haystack.length()) return -1; if(needle[j] != haystack[i + j]) break; } } } };
相关文章推荐
- 【一天一道LeetCode】#28. Implement strStr()
- Leetcode-28. Implement strStr()
- Leetcode28. Implement strStr()
- 28. Implement strStr()-leetcode-java
- 【leetcode】28. Implement strStr()
- LeetCode 28. Implement strStr()
- LeetCode --- 28. Implement strStr()
- leetcode 28. Implement strStr() 实现strStr()函数
- LeetCode - 28. Implement strStr()
- Leetcode 28. Implement strStr() KMP算法解题
- [LeetCode] 28. Implement strStr() 实现strStr()函数
- LeetCode 28. Implement strStr()
- LeetCode笔记:28. Implement strStr()
- python写算法题: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()