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