Data Structures & AlgorithmsHardCodeforces Div2 D · LeetCode-style
The array [7, 2, 5, 10, 8, 3, 6] must be split into exactly 3 contiguous non-empty parts (order kept). What is the smallest possible value of the largest part sum?
- A. 17
- B. 24
- C. 13
- D. 10
Correct answer: A. 17
Binary search the cap: a cap is feasible when a greedy left-to-right split needs at most 3 parts. The largest element and the average are bounds, not answers, because parts must be contiguous.
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
- An array has 10^5 values and you need the k-th smallest value among all pair sums a[i] + a[j] with i < j. Which approach is the right fit?
- From [4, 9, 2, 7, 5, 1] you may pick any elements (each at most once). What is the minimum number of picks so that the picked sum is at…
- How many index triples i < j < k in [-2, -1, 0, 1, 2, 3] have a sum of exactly 0?
- How many contiguous subarrays of [1, 2, 3, 4] have a sum that is a perfect square?
- A string "cdeab" is rotated left by some number of steps k (0 <= k < 5) to become "abcde". What is the smallest such k?
- What is the sum of the maximum over all contiguous subarrays of [3, 1, 2, 4]?