Easy 9 Implement strStr()(28)
来源:互联网 发布:纸质书情怀 知乎 编辑:程序博客网 时间:2024/06/05 12:49
Description
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Solution
暴力法。
class Solution {public: int strStr(string haystack, string needle) { if(haystack.empty()&&needle.empty()) return 0; int m=haystack.size(),n=needle.size(); for(int i=0;i<=m-n;i++){ int j=0; for(;j<n;j++){ if(needle[j]!=haystack[i+j]) break; } if(j==n) return i; } return -1; }};
0 0
- Easy 9 Implement strStr()(28)
- LeetCode-28-Implement strStr()(Sting/穷举)-Easy
- LeetCode OJ 28 Implement strStr() [Easy]
- LeetCode-Easy刷题(9) Implement strStr()
- Leetcode[easy] - Implement strStr()
- 28. Implement strStr() [easy]
- 【Easy】28. Implement strStr()
- 28. Implement strStr() [easy] (Python)
- LeetCode-Easy-Java-Implement strStr()
- LeetCode刷题(C++)——Implement strStr()(Easy)
- LeetCode(28)Implement strStr()
- LeetCode (28)Implement strStr()
- [LeetCode] 028. Implement strStr() (Easy) (C++/Python)
- Easy-题目57:28. Implement strStr()
- Leetcode 28. Implement strStr() (Easy) (cpp)
- (算法分析Week6)Implement strStr()[Easy]
- [C++]LeetCode 28: Implement strStr() (实现strStr()函数)
- LeetCode 28 Implement strStr()(实现strStr()函数)
- Mysql一些问题的总结
- 2017年北京市软考报考名费是68元
- 常用linux命令(2)
- linux压缩和解压缩命令大全
- Linux 设备驱动的固件firmware加载
- Easy 9 Implement strStr()(28)
- 【转2】修改pppd提高多拨成功率
- MySql简单建表语句
- 通过扩展让ASP.NET Web API支持JSONP ----- .NET 4.0 asp.net WebApi(不是WebApi 2)
- R<给*apply函数族中的FUN传递多个参数>
- Tensorflow 入门
- JavaScript 函数的定义-调用、注意事项
- Map集合的四种遍历方式
- LeetCode-6. ZigZag Conversion (JAVA)(之字形转换)