Maximize the value problem

Question · Posted Feb 2023

1. Maximize the Value Rearrange an array of integers so that the calculated value U is maximized. Among the arrangements that satisfy that test, choose the array with minimal ordering. The value of U for an array with n elements is calculated as: U = arr[1]xarr[2]x(1+arr[3])xarr[4]x...xarr[n-1] × (1+arr[n]) if n is odd or  U = arr[1]xarr[2]x(1+arr[3])xarr[4]x...x(1+arr[n-1]) x arr[n] if n is even The sequence of operations is the same in either case, but the length of the array, n, determines ...

The full answer & interview discussion are available to premium members.

Log in Create a free account