28. Implement strStr()

    xiaoxiao2021-03-25  103

    Implement strStr().

    Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

    public int strStr(String haystack, String needle) { if(haystack==null||needle==null||needle.length()>haystack.length()) return -1; return haystack.indexOf(needle); }

    转载请注明原文地址: https://ju.6miu.com/read-16571.html

    最新回复(0)