This is a verified interview question from Amazon-ml-summer-school. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Find the Index of the First Occurrence of the String" covers key patterns like Other.
"Given two strings `s` and `p`, return an index `i` of the first occurrence of `p` in `s`. If `p` occurs multiple times, you must return the **smallest** index. If `p` does not occur in `s`, return `-1`. Any leading zeros in `p` should be treated as such, i.e. the function should return correct value if `p` contains leading zeros. "
Join thousands of developers practicing for Amazon-ml-summer-school.