Substring Pattern Matches

Asked at Apple · Coding & Leetcode-style Questions · Difficulty: Medium · Last asked May 3, 2026

Given a string `s` and a non-empty pattern `pattern`, return **every starting index** `i` in `s` where the substring `s[i..i + pattern.length - 1]` equals `pattern`.

Loading the problem…