Google | onsite | new grad
Anonymous User
3495

Q.1 Given an array of integers and a number m. We can create m subarrays using the input array. The max sum of each subarrays out of each possibilities are taken. Return the minimum number out of them.

Eg: [1 3 9 2 7 8]
m=2

Possibilities------Sum---Max
[1] [3 9 3 7 8]--- 1, 30----30
[1 3][ 9 2 7 8]--- 4, 27----27
[1 3 9][ 2 7 8]---13, 17----17
[1 3 9 2][ 7 8]---15, 15----15
[1 3 9 2 7][ 8]---22, 8----22

ans: 15 (as 15 is min of the all maximum sums)

HINT: overlapping problem

I couldn't come up with the solution. Please if anyone has some approach please let know. Also, if anybody couldn't get the question please let me know through comments I will try to improvise it.

Edits: Array can contain negitives also. Binary search solution won't work in that case

Comments (14)