LeetCode28. Implement strStr()
来源:互联网 发布:js正则匹配网址 编辑:程序博客网 时间:2024/05/21 12:51
LeetCode28. Implement strStr()
题目:
Implement strStr().
Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Example 1:
Input: haystack = "hello", needle = "ll"Output: 2
Example 2:
Input: haystack = "aaaaa", needle = "bba"Output: -1
题目分析:直接用string的find函数
代码:
class Solution { public: int strStr(string haystack, string needle) { int tmp = haystack.find(needle); if (tmp == string::npos) return -1; return tmp; } };
阅读全文
0 0
- [LeetCode28] Implement strStr()
- Leetcode28 Implement strStr()
- LeetCode28:Implement strStr()
- [LeetCode28] Implement strStr()
- Leetcode28: Implement strStr()
- Leetcode28. Implement strStr()
- leetcode28: Implement strStr()
- leetcode28. Implement strStr()
- leetcode28. Implement strStr()
- LeetCode28. Implement strStr()
- leetcode28 Implement strStr()
- LeetCode28. Implement strStr()
- LeetCode28——Implement strStr()
- 【LeetCode28】【 Implement strStr()】length,length(),size()
- Sunday算法的一种Java实现(Leetcode28. Implement strStr())
- Implement strStr()
- Implement strStr()
- Implement strStr()
- 基因数据处理69之bowtie安装与使用
- ll -bash: ls: command not found
- 02爬虫---浏览器的模拟Headers属性
- 基因数据处理70之Picard安装没成功
- 基因数据处理71之GRCH38 的chr14提取
- LeetCode28. Implement strStr()
- 关于支持向量机(SVM)
- Sublime Text 无法使用Package Control或插件安装失败的解决方法
- 基因数据处理72之GATK安装成功
- 171219 JarvisOJ(DebugMe)(1)
- 数据结构-最短路径
- Scrapy命令行参数化动态生成url
- java日期格式规范(JDK1.8官方文档)
- X^2 Mod P