Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

From [7, 2, 9, 4, 6, 1], delete exactly one contiguous block of length 2. What is the smallest possible value of (max minus min) of the remaining array?

  1. A. 6
  2. B. 8
  3. C. 9
  4. D. 1

Correct answer: A. 6

Try each length-2 block: removing [2, 9] leaves 7, 4, 6, 1 (spread 6) and removing [9, 4] leaves 7, 2, 6, 1 (spread 6); the others leave 8 or 7. 8 is the original spread, which a bad deletion keeps; 9 and 1 are single extreme values, not spreads.

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

Exams that ask this topic