leetcode Implement strStr()

来源:互联网 发布:淘宝卖家说加微信返现 编辑:程序博客网 时间:2024/05/24 05:49

题目链接这里

public class Solution {    public int strStr(String haystack, String needle) {        out:for(int i=0;i<haystack.length()-needle.length()+1;i++)        {            for(int j=0;j<needle.length();j++)            {                if(haystack.charAt(i+j)!=needle.charAt(j))                {                    continue out;                }            }            return i;        }        return -1;    }}
0 0
原创粉丝点击