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?
- A. 7
- B. 8
- C. 6
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many integers x in [1, 500] have digit sum equal to 10?
- How many unordered pairs {a, b} with a < b and 1 <= a, b <= 30 have a b a perfect square?
- An array is [1, 2, 1, 2, 1, 2] (indices 0 to 5). How many pairs of even-indexed positions i < j hold equal values?
- What is the sum of all proper divisors of 220 (divisors less than 220)?
- How many integers in [1, 100] have an odd number of positive divisors?
- What is the last digit of 3^2024?