Exercises/#120 Implement strStr (Find Substring)
#120

Implement strStr (Find Substring)

EasyπŸ”€ Strings
40 XP

Problem

Given strings haystack and needle, return the index of the first occurrence of needle in haystack, or -1 if not found.

Examples

Input: haystack = 'sadbutsad', needle = 'sad'
Output: 0

Input: haystack = 'leetcode', needle = 'leeto'
Output: -1
stringsliding-window
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

120 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features