Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: In the array [9, 2, 6, 4, 7, 1], what is the number of elements that are smaller than every element to their left (strict left minima, with the first element counted)?

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

Correct answer: D. 3

Count the running minimum records: 9, then 2, then 1. The values 6, 4 and 7 are not smaller than the running minimum at their positions.

More Coding Interview Problems questions

Exams that ask this topic