You're optimizing video chunks for streaming. Each chunk has a size represented in a 0-indexed array nums. To ensure smooth playback, chunk sizes must be in non-decreasing order.
You can split any chunk into two smaller chunks whose sizes add up to the original.
For example, if nums = [10,5,8], you can split 10 into [4,6] making it [4,6,5,8].
Return the minimum number of split operations needed to make the array sorted in non-decreasing order.
The candidate was able to come up with an O(n^2) solution within 15 minutes but was asked to improve it to O(n), which they couldn't achieve.
Examples
01 · Example 1
nums = [10, 5, 8] return = 1
:) The output may be 1. If anything is found to be wrong, I am more than happy to make modifications.
More Google problems
- Consolidate On-Call RotationsOA · Seen Jun 2026
- Detonate Bombs with Chain ReactionsONSITE INTERVIEW · Seen May 2026
- Evaluate a Nested Math ExpressionONSITE INTERVIEW · Seen May 2026
- Tic-Tac-Toe Game StatusPHONE SCREEN · Seen May 2026
- Longest Dictionary TokenizationPHONE SCREEN · Seen May 2026
- Minimum Cars for Rental RequestsONSITE INTERVIEW · Seen Apr 2026
- Shortest Path with Mandatory WaypointONSITE INTERVIEW · Seen Apr 2026
- Count Divisible Coin SelectionsOA · Seen Dec 2025
public int minSplitOperations(int[] nums) {
// write your code here
}
nums[10, 5, 8]
expected1
sign in to submit