I need an approach to solve this question.

Revision en1, by tusharjape007, 2019-01-26 16:18:38

I recently encountered a question on a contest organised by CodeNation which is as follows.

You have been give an array comprising of numbers (ranging from -10^9 to +10^9) and the value of an array is defined as the sum of the absolute differences between each pair of consecutive entries in the array. You are allowed to reverse a contiguous subarray of the given array. What would be the maximum possible value of the array if you apply the given operation utmost once?

I am stuck on the O(n^2) approach to this problem. Can anyone please help me out?

Tags array

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English tusharjape007 2019-01-26 16:18:38 602 Initial revision (published)