Data Structures & AlgorithmsVery hardGoogle · Arrays

What is the maximum sum of a non-empty contiguous subarray of [3, -4, 2, -3, -1, 7, -5] if you may delete at most one element from the chosen subarray (the remaining elements keep their order and sum)?

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

Correct answer: A. 8

Take 3, -4, 2, -3, -1, 7 and delete -4: 3 + 2 - 3 - 1 + 7 = 8; without any deletion the best is 7.

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

Exams that ask this topic