Quant Memo
Coding/●●●●

Remove k digits to get the smallest price

Asked at DRW, Five Rings

Given a number as a digit string, delete exactly k digits so the remaining digits (in their original order) form the smallest possible number. Do not reorder digits, and strip any leading zeros from the result.

num = "1432219", k = 3  ->  "1219"
num = "10200",   k = 1  ->  "200"
num = "10",      k = 2  ->  "0"

Return the smallest number achievable after removing exactly k digits.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions