Given a string, write an efficient algorithm to perform a substring search and return its starting index.