LeetCode3.2 @ Implement strStr() D4F5
来源:互联网 发布:综合管线设计软件 编辑:程序博客网 时间:2024/05/29 16:52
Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
Wiki:A Needle in a haystack is a figure of speech used to refer to something that is difficult to locate in a much larger space.
来源于http://blog.csdn.net/linhuanmars/article/details/20276833
注意总结::
【模型】两个字符串或数组,注意for循环的写法
public class Solution { public String strStr(String haystack, String needle) { if(haystack==null || needle==null || needle.length()==0) return haystack; if(haystack.length()<needle.length()) return null; for(int i=0;i<=haystack.length()-needle.length();i++){ boolean successFlag=true; for(int j=0;j<needle.length();j++){ if(haystack.charAt(i+j)!=needle.charAt(j)){ successFlag=false; break; } } if(successFlag) return haystack.substring(i); } return null; } }
0 0
- LeetCode3.2 @ Implement strStr() D4F5
- LeetCode3.2(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()
- linux中的设备节点
- openwrt的samba使用
- String、StringBuffer和StringBuilder的区别
- 升级 eudev-1.9 启动信息出现错误
- 如何清理释放 Android 手机内存空间
- LeetCode3.2 @ Implement strStr() D4F5
- 分区表的总结(一)
- 哈哈哈,搞定OPENWRT上REAVER不能PIN了。降libpcap到1.1.1版本就行了
- 设计模式学习笔记——命令模式
- get 和 post 的详细比较
- [Leetcode] Climbing Stairs
- mac下配置adb
- Java中集合List,Map和Set的区别
- 设计模式学习笔记——观察者模式