For large k shows wrong ans


code is working fine for smaller values. please check.

@Krishna-Singh-2678805765519156 dont typecaste the power to int

it is working but can you tell me the reason why?

@Krishna-Singh-2678805765519156 if the value of mid is high pow can return a really high value, if you typecaste it to int it might end up as a completely different number altogether and mess up the binary search

you mean it will go out of the range of int or even long long,but as pow returns double it can hold that large value also? thanx a lot for clearing this deeper concept

1 Like

@Krishna-Singh-2678805765519156 yes that’s correct! it will work fine as long as we dont typecaste it explcitly (like you did) or implicitly(by assigning it to some variable )

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.

1 Like