Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

Remove exactly 3 digits from the number 1432219 (without reordering the rest) so that the remaining number is as small as possible. What is the resulting number?

  1. A. 1132
  2. B. 1229
  3. C. 1239
  4. D. 1219

Correct answer: D. 1219

A monotonic stack deletes a larger digit whenever a smaller digit arrives, while deletions remain. Deleting the leftmost large digits greedily is the common trap.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic