Factorial problem

In this why ans will be = to int max, if cnt=0,occur=1,then ans=min(ans,0) which is automatically zero so why to check?

@guptashubham210a there is nothing wrong with placing a few additional checks to ensure that you never get the wrong answer…you can remove them later if you find that they are not needed but it is better to be on the safe side

but in this condn why ans will be int max?

@guptashubham210a in case such a value of x does not exist to satisfy our condition, it will not get updated and remain INT_MAX.
Again, if you can find that logically that condition is never needed, feel free to remove it but only if you are 100% sure

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.