You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your code. But I found an issue in you code, as below snippet:
if (a >= len1 || haystack.charAt(a) != needle.charAt(b)) {
match = false;
break;
}
I think that we can change it to:
if ( haystack.charAt(a) != needle.charAt(b)) {
if (a >= len1) return null;
match = false;
break;
}
will make sense.
https://github.com/mengli/leetcode/blob/master/ImplementStrStr.java#L22
Thanks for your code. But I found an issue in you code, as below snippet:
if (a >= len1 || haystack.charAt(a) != needle.charAt(b)) {
match = false;
break;
}
I think that we can change it to:
if ( haystack.charAt(a) != needle.charAt(b)) {
if (a >= len1) return null;
match = false;
break;
}
will make sense.