Oracle OA | NIT R | 2023 | Maximum Array Value | University Country List | Aladdin and his Carpet

Oracle · Question · Posted Jul 2023

  Question 1: Maximum Array Value Given an array arr of n positive integers, the following operation can be performed any number of times. Use a 1-based index for the array. • Choose any such that 2s is n. • Choose any x such that 1 sxs arr[i] • Set arr[i-1] to arr[i-1]+x • Set arr[i]to arr[i]-x Minimize the maximum value of arr using the operation and return the value. Example n=4 arr = [1, 5, 7, 6] Assuming 1-based ...

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

Log in Create a free account