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