Code Room
CodingEasy
Question
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.