Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

For [3, 1, 4, 2], split into a non-empty prefix and a non-empty suffix. For each split compute (minimum of prefix) times (maximum of suffix), then take the largest value. What is it?

  1. A. 13
  2. B. 12
  3. C. 10
  4. D. 4

Correct answer: B. 12

Try each split point: prefix minima and suffix maxima give 3 * 4 = 12, 1 * 4 = 4 and 1 * 2 = 2. The best is 12 with the split after the first element.

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

Exams that ask this topic