Code Room
CodingMediumcod-g1399
Subject StringsLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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) → str
Examples
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.