This is question https://hack.codingblocks.com/app/practice/3/70/problem this is my code https://ide.codingblocks.com/s/379005

this is question https://hack.codingblocks.com/app/practice/3/70/problem this is my code https://ide.codingblocks.com/s/379005

Hey @dhruvilcodes
Your approach will not work for very large input. Since you are just multiplying all the numbers to check.
Each number can be of order 10^10, so multiplying all of them will result in a very huge number which cannot be store in any datatype.

See the constraints
A[i] <10^10 and n<10^5

In worstcase cumulative product can be (10^10)^(10^5)
Which u cat store anywhere

Consider an i/p
5
690715844 967573868 1501528738 1497214228 1046512263
and check yourself

Follow this for the approach:

long long findMinValue(long long arr[], long long n) {
   long double sum = 0;
   for (int i=0; i<n; i++)
   sum += (long double)log10(arr[i])+EPS;
   long double xl = (long double)(sum/n+EPS);
   long double res = pow((long double)10.0, (long double)xl) + EPS;
   return (long long)ceil(res+EPS);
}
1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.