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?
- A. 6
- B. 8
- C. 9
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many integers from 1 to 50 inclusive have no two adjacent 1-bits in binary?
- Remove exactly two elements from [4, 1, 5, 2, 3] to maximise the sum of what remains. What is the maximum remaining sum?
- How many distinct two-character substrings occur in "mississippi"?
- Perform two operations on [8, 5, 3, 9]: each operation takes the current largest value x and replaces it with floor(x / 2). What is the…
- How many integers n with 1 <= n <= 1000 have n^2 divisible by 36?
- How many palindromic substrings of length at least 2 occur in "aaa" (counted by position)?