Substring search
Implement substring search by hand. Given a text and a pattern, return the index of the first occurrence of the pattern in the text, or -1 if it never occurs. An empty pattern matches at index 0. Use a direct character-by-character scan — no regex and no built-in search helpers. For example, the pattern 'sad' first occurs in 'sadbutsad' at index 0.
Implement
index_of(text: str, pattern: str) → intExamples
in
["sadbutsad","sad"]out0What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
["sadbutsad","sad"]0not run yetsample