Open king-lxt opened 3 years ago
/**
* @param {string} haystack
* @param {string} needle
* @return {number}
*/
var strStr = function (haystack, needle) {
if (needle.length === 0 || haystack.length === 0 && needle.length === 0) {
return 0;
}
if (haystack.length === 0) {
return -1;
}
return haystack.indexOf(needle);
};