Code RoomLint indentation rules
MediumPrep Room Coding #721

Lint indentation rules

CodingAlgorithms & data structuresEntry–Mid~14 min

Lint the indentation of a nested CI file. Rules: (a) leading indentation consists of spaces — if the first character after the leading spaces is a tab, the line is bad; (b) the space count must be even (level = spaces/2); (c) the first non-blank line must be at level 0; (d) compared with the previous non-blank line, a line may go deeper by at most ONE level, while any decrease is fine; (e) whitespace-only lines are invisible to all rules. Return true when every line passes, false at the first violation. An empty file is valid.

Implement
validate_indentation(lines: list[str]) → bool
Examples
in[["deploy:"," region: us-east"," "]]outtrue
in[["jobs:"," build: go"]]outfalse
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 14 min
InputExpectedGot
[["deploy:"," region: us-east"," "]]truenot run yetsample
[["jobs:"," build: go"]]falsenot run yetsample