Algorithms—28.Implement strStr()
来源:互联网 发布:日本女孩做饭知乎 编辑:程序博客网 时间:2024/05/18 02:13
思路:没太理解题目的意思,直接暴力破解。
public class Solution { public int strStr(String haystack, String needle) { if (needle.length()==0) {return 0;} for (int i = 0; i <haystack.length()-needle.length()+1; i++) {if (haystack.substring(i,i+needle.length()).equals(needle)) {return i;}} return -1; }}
耗时:324ms,中下游。
0 0
- Algorithms—28.Implement strStr()
- Leetcode刷题记——28. Implement strStr(实现strStr)
- 28. Implement strStr() ——Java
- [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()
- 你是码农还是优秀程序员?
- COPY 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- Server Tomcat v7.0 Server at localhost failed to start
- 计算程序运行时间,精确到毫秒级
- java Map接口源码分析
- Algorithms—28.Implement strStr()
- java集合(ArrayList)
- [二分]poj3061 Susequence
- srandom((unsigned)time(NULL))
- 编译wget
- Java之泛型【入门版,实例解析】
- 虚拟机内删除文件后减少qcow2虚拟磁盘文件实际占用的存储空间
- 学习:WordXML格式初步分析
- 【Android】TypedArray和obtainStyledAttributes使用(R.styleable.xx_xx)