Find minimum value to assign all array elements so that array product becomes greater

Правка en1, от wish_me, 2017-09-19 16:17:40

Given an array arr[] of n elements,

update all elements of given array to some minimum value x i.e, arr[i] = x (0 <= i < n),

such that product of all elements of this new array is strictly greater than the product of

all elements of the initial array, where 1 <= arr[i] <= 10^10 and 1 <= n <= 10^5

Input : arr[] = [4, 2, 1, 10, 6]

Output : 4

4 is the smallest value such that

4 * 4 * 4 * 4 * 4 > 4 * 2 * 1 * 10 * 6

Input : arr[] = [100, 150, 10000, 123458, 90980454]

Output : 17592

Expected time Complexity:O(N)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский wish_me 2017-09-19 16:17:40 635 Initial revision (published)