Data Structures & AlgorithmsHardGATE CS · TCS NQT

Remove exactly 2 digits from "7419" (keeping order) to make the largest possible number. What is the result?

  1. A. 74
  2. B. 79
  3. C. 19
  4. D. 41

Correct answer: B. 79

A monotonic stack removes a smaller digit whenever a larger one arrives, as long as deletions remain. The largest result keeps the 7 and then the 9 at the front, giving 79.

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

Exams that ask this topic