Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the number of elements remaining in the list after deleting each element that is smaller than the element immediately before it, applied once in a single left-to-right pass over the original list [5, 2, 8, 1, 9, 3, 7]?

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

Correct answer: C. 4

The first element always stays, and each later element stays unless it is smaller than its original predecessor. Comparing against the already-deleted neighbour changes the count.

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

Exams that ask this topic