Code RoomRepeated substring pattern
MediumPrep Room Coding #590

Repeated substring pattern

CodingAlgorithms & data structuresEntry–Mid~16 min

Detect whether a non-empty lowercase string can be built by repeating one of its substrings two or more times. Return True if such a building block exists, False otherwise. For example, 'abab' is 'ab' repeated twice and 'abcabcabc' is 'abc' repeated three times, but 'aba' and 'abcab' cannot be built this way.

Implement
has_repeated_pattern(s: str) → bool
Examples
in["abab"]outtrue
What 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 16 min
InputExpectedGot
["abab"]truenot run yetsample