Getting RTE for CK87GSUB

My Java Solution for CK87GSUB is getting RTE although I have no clue of the reason. Someone please specify the bug ? Also it would be helpful if a simple explanation could be provided ?

My Solution : CodeChef: Practical coding for everyone

Hey @jagreetdg

Your code fails at this test case. It gives a wrong answer.

Your code gives a RTE at this test case.

You are calculating the factorial of length of the string and if the length becomes greater than 22 then there is a case for long overflow condition. The return value becomes greater than the maximum value of long so you need to change your approach a bit.

1 Like