28. Implement strStr()

原题链接:https://leetcode.com/problems/implement-strstr/description/
简单的题目就是简单,比如这道题目我直接调用 JDK String 类的方法就实现了。。。

class Solution {
    public int strStr(String haystack, String needle) {
        return haystack.indexOf(needle);
    }
}

直接使用 JDK 的时间,确实通过了。但是,如果要自己实现 indexOf 方法确实有一定难度的,就只能上串模式匹配算法了:http://www.cnblogs.com/optor/p/8463490.html

原文地址:https://www.cnblogs.com/optor/p/8572157.html