Code Room
CodingMediumcod-g1450
Subject GreedyLevel Entry–Mid~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a string of digits num (no sign, possibly with leading zeros after deletions) and an integer k, delete exactly k digits so that the remaining digits, kept in order, read as the smallest possible number. Return that number as a string without unnecessary leading zeros; return '0' if nothing remains or only zeros remain. Example: num '1432219' with k = 3 gives '1219'.

Implement
smallest_after_removals(num: str, k: int) → str
Examples
in["1432219",3]out"1219"
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.