Code Room
CodingMediumcod-g625
Subject StringsLevel Mid–Senior~24 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a string num representing a non-negative integer and an integer k, remove exactly k digits so the resulting number is the smallest possible. Return it as a string with no leading zeros (return '0' if the result is empty or all zeros). 1 <= len(num) <= 100000, 0 <= k <= len(num). Example: num='1432219', k=3 -> '1219'.

Implement
remove_k_digits(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.