Binary Search pattern
Split Array Largest Sum
Given an array of non-negative integers and an integer k, split the array into k non-empty contiguous subarrays so that the largest subarray sum is minimized, and return that minimized largest sum. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 410
- Hard
- 2 approaches
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Binary SearchLeetCode 410
Hard
From the first idea to the best one
- 01 Brute force · try every cut O(nᵐ⁻¹)O(1) space
- 02 Optimized · binary search the answer O(n log Σ)O(1) space
What you will learn
- How to read Split Array Largest Sum and spot the binary search pattern in it
- Brute force · try every cut: O(nᵐ⁻¹) time, O(1) space
- Optimized · binary search the answer: O(n log Σ) time, O(1) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Binary Search
- Kth Smallest in a Sorted MatrixLC 378 · Medium
- Minimum Shipping CapacityLC 1011 · Medium
- OverviewConcept
- Binary SearchLC 704 · Easy
- Search Insert PositionLC 35 · Easy
- Peak Index in a Mountain ArrayLC 852 · Medium
- Maximum Candies Allocated to K ChildrenLC 2226 · Medium
- Apple Harvest (Koko Eating Bananas)LC 875 · Medium
See Split Array Largest Sum run, step by step
Sign in and this page opens on the animation, with all 11 Binary Search problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.