wish_me's blog

By wish_me, history, 7 years ago, In English

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)

  • Vote: I like it
  • -16
  • Vote: I do not like it