Code RoomDoor panel codes
EasyPrep Room Coding #4791

Door panel codes

CodingAlgorithms & data structuresEntry–Mid~15 min

A door panel unlocks when a finger slides across its keys rather than tapping them. key_rows gives the pad one row at a time, every row the same width, and each character is either a key label or a dot for a dead cell no finger may touch. Labels are single characters and no label repeats. A code starts at start_key, and each key after that must sit directly above, below, left or right of the key before it, never diagonally. No key may be used twice. Return every code of exactly code_length keys, each written as its labels run together with nothing between them, sorted in ascending order. Return an empty list when the pad has no rows, when start_key is not printed on the pad, or when no code of that length exists.

Implement
list_swipe_codes(key_rows: list[str], start_key: str, code_length: int) → list[str]
Examples
in[["123","456","789"],"5",3]out["521","523","541","547","563","569","587","589"]
in[["12","34"],"1",4]out["1243","1342"]
in[["12","3."],"1",3]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 15 min
InputExpectedGot
[["123","456","789"],"5",3]["521","523","541","547","563","569","587","589"]not run yetsample
[["12","34"],"1",4]["1243","1342"]not run yetsample
[["12","3."],"1",3][]not run yetsample