Error int his output

sir this is a hackerblock problem
https://hack.codingblocks.com/app/practice/3/70/problem


can you please check it

This approach is completely wrong

try for this input
5
1 2 3 4 5

correct ans is 3
but your code will not give any ans it will give garbage value
because final_product will never be > initial_product

try again and first run your code with some your testcases

if you not able to think any approach
i will help you
feel free to ask

sir then what is the right approach for this question

you have to use binary search
and to avoid overflow
instead of multiplying numbers take log of them

arr[0] * arr[1] * arr[2] < x*n
instead of checking this you can also check
log(arr[0]) + log(arr[1]) + log(arr[2] < n log(x) (taking log both side)

Reference Code

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.