Search
⌘K

Leetcode 1712. Ways to Split Array Into Three Subarrays

Count the number of ways to choose two split indices to partition the array into three non-empty contiguous subarrays (left, mid, right) such that sum(left) ≤ sum(mid) ≤ sum(right). Because nums are non-negative, prefix sums are non-decreasing, so you can use two pointers or binary searches on prefix sums to count valid mid-split ranges for each left split (answer mod 1e9+7).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.