28. Implement strStr()
来源:互联网 发布:linux c list用法 编辑:程序博客网 时间:2024/05/29 06:58
class Solution {public: int strStr(string haystack, string needle) { int nl = needle.size(), hl = haystack.size(), ret = 0; if(nl == 0) return 0; if(hl == 0) return -1; for(; ret < hl - nl + 1; ret++) { if(haystack.at(ret) == needle.at(0) && haystack.substr(ret, nl) == needle) return ret; } return -1; }};
class Solution {public: int strStr(string haystack, string needle) { return haystack.find(needle, 0); }};
阅读全文
0 0
- [LeetCode]28.Implement strStr()
- LeetCode --- 28. Implement strStr()
- LeetCode 28.Implement strStr()
- [Leetcode] 28. Implement strStr()
- 28. Implement strStr()
- 【leetcode】28. Implement strStr()
- [leetcode] 28.Implement strStr()
- Leetcode-28.Implement strStr()
- 28. Implement strStr()
- 28. Implement strStr()
- 28. Implement strStr()
- 28. Implement strStr() LeetCode
- 28. Implement strStr()
- leetcode 28. Implement strStr()
- [LeetCode]28. Implement strStr()
- 28. Implement strStr()
- 28. Implement strStr()
- 28. Implement strStr()
- js(四)---预编译
- MATLAB 2015b randi函数生成随机均匀分布信号的用法
- MCU的编译和基本知识学习(1223)
- Android ADB批处理脚本
- MySQL5.6中limit的工作机制和order by limit优化原理
- 28. Implement strStr()
- 常用软件
- SSL P1643 最小乘车费用
- 转:十步制胜 Kaggle 数据科学竞赛
- 内存泄漏
- Python 字典(Dictionary) setdefault()方法
- phpstrom中自动补全命名空间
- 整理手套
- Java实现给图片添加水印详细教程二