Find the Index of the First Occurrence in a String
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.
Find the Index of the First Occurrence in a String

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:
Input: {"haystack":"sadbutsad","needle":"sad"}
Output: 0
Input
arr ={"haystack":"sadbutsad","needle":"sad"}

Find needle in haystack

s
s0a1d2b3u4t5s6a7d8
t
s0a1d2
Variables
VariableValue
haystacksadbutsad
needlesad
DepthFunction Call
Stack empty
0/1