28. Implement strStr()
来源:互联网 发布:学python工作后累不累 编辑:程序博客网 时间:2024/06/06 01:11
28. 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
代码:
package String;/*** @Author OovEver* @Date 2017/12/6 10:55*/public class LeetCode28 { 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.charAt(j) != haystack.charAt(i + j)) { break; } } } }}
阅读全文
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()
- idea mac 修改签名
- Java 深入学习(13) —— final 关键字
- SpringSecurity2 session超时跳转登陆界面
- docker部署shipyard容器管理工具
- shell脚本中与文件判断相关的指令
- 28. Implement strStr()
- Android 在线下载更新App 下载完成安装APK(兼容Android7.0)
- android app测试相关
- 按周统计时如何把日期转换为一周的时间段并按周累加
- Unity 方向键输入 Input.GetAxis() 和Input.GetAxisRaw()
- leetcode_145. Binary Tree Postorder Traversal ? 待解决
- es6学习-let,const
- A02_IO路径管理
- 将Tomcat添加到服务中