Data Structures & AlgorithmsModerate
In how many ways can 1 2 2 0 3 2 1 2 2 be cut into exactly THREE non-empty contiguous parts whose sums are all equal? (A cut is a pair of positions.)
- A. 3
- B. 2
- C. 4
- D. 1
Correct answer: B. 2
Each part must have sum total/3, so the valid cut positions are the prefix sums equal to total/3 and 2·total/3 with the first cut before the second. Counting two-part splits or forgetting the strict order of the two cuts gives different totals.
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
- What is the maximum AVERAGE over all contiguous subarrays of 1 12 -5 -6 50 3 that have length at least 3? Give the answer as a fraction in…
- Choose two NON-OVERLAPPING contiguous windows of length exactly 2 from 4 -2 7 1 -5 6 3 -1. What is the largest possible total sum of their…
- How many contiguous subarrays of 3 1 2 4 0 contain EXACTLY 2 inversions (pairs i < j inside the subarray with a[i] > a[j])?
- What is the length of the longest contiguous subarray of 1 3 5 4 2 6 8 7 3 1 that is bitonic, meaning it strictly increases up to one peak…
- How many contiguous subarrays of 2 1 4 7 3 2 5 3 1 are mountains? A mountain has length at least 3, strictly increases to a single peak…
- In the sorted array 1 3 4 7 9 12 14, how many index pairs i < j satisfy A[j] − A[i] ≥ 5?