Divide the array such that the sum of Max-Min in the subarray is maximum | Interview que
Anonymous User
154

Given an array, divide the array such that the sum of (max-min in the subarray) is maximum.
output: no. of subarray and maximum sum of maximum minus minimum of the subarray.
e.g [3,1,4,6,2]
ans=>no.of subarray=2, max sum=3+4=7 ([3,1,4], [6,2])

Can someone suggest the solution?

Comments (1)