Expand tabs
A log viewer renders tabs with 4-column tab stops. Given a single line (no newlines), replace each tab with one to four spaces so that the character after the tab lands on the next multiple of 4 — counting columns from 0 over the output produced so far. All other characters occupy one column each. For example, 'ab\tc' becomes 'ab c' (two spaces bring column 2 to 4), and '\t' alone becomes four spaces.
Implement
expand_tabs(line: str) → strExamples
in
["ab\tc"]out"ab c"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
solution.py
InputExpectedGot
["ab\tc"]"ab c"not run yetsample