Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

Remove exactly one element from [5, -4, 3, -7, 2], then take the maximum product of two distinct remaining elements. What is that maximum product?

  1. A. 29
  2. B. 26
  3. C. 28
  4. D. 35

Correct answer: C. 28

Try each removal and take the best pair product of the remaining four values. Keeping the two largest positives without considering the negatives misses the pair (-7, -4) type candidates.

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

Exams that ask this topic