Code RoomRepeated gene blocks
EasyPrep Room Coding #4710

Repeated gene blocks

CodingAlgorithms & data structuresEntry–Mid~16 min

A gene sequencer writes its calls as one long code string of uppercase letters. The calibration report slides a window of fixed width along that code, one character at a time, and flags any window whose exact contents already appeared at an earlier position, since a repeated block that size usually means the instrument latched. Given the code and the block width, return every distinct block that appears two or more times, sorted in ascending order by ordinary string comparison. List each repeated block once, no matter how many times it shows up. Return an empty list when the width is zero or negative, or wider than the code itself. Windows overlap: in AAAA a width of 2 yields the blocks AA, AA and AA, so AA is repeated.

Implement
repeated_block_codes(code: str, block: int) → list[str]
Examples
in["ACGTACGTTT",4]out["ACGT"]
in["ACGTACGTACGT",3]out["ACG","CGT","GTA","TAC"]
in["ABCDEF",2]out[]
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
["ACGTACGTTT",4]["ACGT"]not run yetsample
["ACGTACGTACGT",3]["ACG","CGT","GTA","TAC"]not run yetsample
["ABCDEF",2][]not run yetsample