
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Create a prefix array to efficiently find the sum of subarrays.
As we are dividing the array into three subarrays, there are two "walls". Iterate over the right wall positions and find where the left wall could be for each right wall position.
Use binary search to find the left-most position and right-most position the left wall could be.