Implement strStr()
来源:互联网 发布:linux 关闭oracle进程 编辑:程序博客网 时间:2024/06/04 19:53
坚刚不可夺其志的主子
public int strStr(String haystack, String needle) { if (haystack == null || needle == null || haystack.length() < needle.length()) { return -1; } //for (int i = 0; i < haystack.length(); i++) { //for (int i = 0; i < haystack.length() - needle.length(); i++) { for (int i = 0; i <= haystack.length() - needle.length(); i++) { int j = 0; for (; j < needle.length(); j++) { if (haystack.charAt(i + j) != needle.charAt(j)) { break; } } if (j == needle.length()) { return i; } } return -1; }
0 0
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Implement strStr()
- Centos 6.4 python 2.6 升级到 2.7
- 图像RGB2YUV与YUV2RGB格式互转介绍
- 算法导论第六章-堆排序-Cpp代码实现
- JavaScript学习
- 深入剖析ThreadLocal
- Implement strStr()
- 自定义属性
- (4.3.2.10)android:descendantFocusability用法简析
- Rootkit技术的主要原理
- Servlet 3.0特性详解
- [Practice Round APAC test 2016]Problem A. Bad Horse(Google 2016笔试题)
- Win10下eclipse中打开图片乱码
- 错误:no acceptable C compiler found in $PATH
- Vim常用插件及配置