Data Structures & AlgorithmsHardTCS NQT · Accenture

A passenger count changes by +3, -1, +2, -2, +4, -3 at successive stops, starting from 0. What is the maximum number of passengers on board at any time?

  1. A. 7
  2. B. 8
  3. C. 6
  4. D. 10

Correct answer: C. 6

The running totals are 3, 2, 4, 2, 6, 3, so the peak is 6. The final count of 3 is not the maximum.

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

Exams that ask this topic