Hi Anshuman Singh I am getting partailly correct ans alongwith below error :- Wro


Hi Anshuman Singh I am getting partailly correct ans alongwith below error :-
Wrong Answer. Your program’s output doesn’t match the expected output. You can try testing your code with custom input and try putting debug statements in your code.
Your code may have an overflow issues. Make sure you are typecasting variables before arithmetic operations correctly.

Can you pls explain it further ie was there really a wrong ans or it is just TLE? Thanks.


Its not a TLE.
Your solution might have overflow issues which is why it does not work for larger integers.


Anshuman SinghThanks for the quick revert. Finally improvised on the solution further and now it is accepted.
Why I think that it was due to TLE is because :-
a)the error stack trace itself was shown under time complexity
b)Secondly I do not think I have changed the existing logic of code ie for which I was getting the above error & just improvised it further so that it should take minimum possible time & post that it accepted.


Sushant Bhalla Hm, I looked at your code. You are using Math.pow. Math.pow is meant for doubles which is why it looses precision for higher powers.
For the same reason, your program does not give the right answer for larger integers.
Take number like 9446865 as input to both your versions of the code.


Anshuman Singh Hi, You are completely correct on "Math.pow is meant for doubles"but I figured out that the problem was not because of loss of precision but was because of one incorrect condition due to which it was not calculating the result completely.
Still, Thanks for your quick & helpful suggestion.