[ LeetCode ] 28 Find the Index of the First Occurrence in a String

codesver·2023년 3월 27일
0

LeetCode

목록 보기
12/24
post-thumbnail

Link | LeetCode 28번 문제 : Find the Index of the First Occurrence in a String

📌 About

문자열을 다루는 문제이다. 문자열에서 indexOf()를 이해하고 있으면 쉽게 해결이 가능하다.

string.indexOf(String)은 string에서 String의 시작 index를 찾으며 없으면 -1을 반환한다.

📌 Code

GitHub Repository

fun strStr(haystack: String, needle: String): Int = haystack.indexOf(needle)
profile
Hello, Devs!

0개의 댓글