28. Find the Index of the First Occurrence in a String
Medium
Given two strings needle
and haystack
, return the index of the first occurrence of needle
in haystack
, or -1
if needle
is not part of haystack
.
Example 1:
Example 2:
Constraints:
1 <= haystack.length, needle.length <= 10^4
haystack
andneedle
consist of only lowercase English characters.
解ι‘
Runtime: 0 ms, faster than 100%
Memory Usage: 2 MB, less than 36.4%
ε¨θ§£ηηε°ηε¦δΈεη²Ύε¦η解ζ³οΌ
Last updated