Link | LeetCode 28번 문제 : Find the Index of the First Occurrence in a String
문자열을 다루는 문제이다. 문자열에서 indexOf()를 이해하고 있으면 쉽게 해결이 가능하다.
string.indexOf(String)은 string에서 String의 시작 index를 찾으며 없으면 -1을 반환한다.
fun strStr(haystack: String, needle: String): Int = haystack.indexOf(needle)