Created
November 7, 2017 13:19
-
-
Save LeeXun/c2811c36001c2ad0d21e372c2002e44c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function isSubstring(a, b) { | |
let i = 0 | |
while(i < a.length - b.length){ | |
let j = 1 | |
if(a[i] == b[0]){ | |
while(true){ | |
if(a[i+j] == b[j]){ | |
if(j == b.length - 1){ | |
return i + j | |
} | |
j += 1 | |
continue; | |
} else { break; } | |
} | |
} | |
i += 1 | |
} | |
return -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment