Data Structures & AlgorithmsHardTCS NQT · Infosys

Starting at index 0 of the array [4, 8, 5, 2, 25], repeatedly jump to the next strictly greater element (a monotonic stack gives these jumps). How many jumps are made before no greater element exists?

  1. A. 2
  2. B. 3
  3. C. 1
  4. D. 4

Correct answer: A. 2

Jumps go 4 to 8 to 25. The element 5 is never reached because the chain skips it, so counting every element that is smaller than the target is wrong.

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

Exams that ask this topic