Data Structures & AlgorithmsVery hardGATE CS

From the digit string 1432219836475, exactly 5 digits are deleted (the remaining digits keep their order, and leading zeros are not an issue here). What is the smallest number that can be obtained?

  1. A. 14322198
  2. B. 19836475
  3. C. 11836475
  4. D. 14322134

Correct answer: C. 11836475

The greedy stack method (pop a larger digit when a smaller one arrives, while deletions remain) gives 11836475, confirmed by checking all subsequences. Simply deleting the 5 leading digits gives 19836475.

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

Exams that ask this topic