Data Structures & AlgorithmsModerateTCS NQT · Codeforces Div2 B

What is the maximum product of exactly 3 consecutive elements of [2, -3, 4, -1, 5, -6, 2]?

  1. A. 20
  2. B. 30
  3. C. 15
  4. D. -4

Correct answer: B. 30

A window of fixed length k with an explicit product for each start is enough here, since the array is short. A running product fails in general because a zero or sign flip changes the whole window.

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

Exams that ask this topic