Chewbacca & Numbers

I’m getting runtime error for two test cases, probably for very large numbers but I fail to understand why. The time complexity of my solution should be O(N) where N is the number of digits. Please help where I’m wrong

Hi @harshvapilani,
The question says that you have to take a number of range 10^18 but you took int in your code which will restrict the range till 10^9.Hence i have changed your code and removed int from certain places and added long in their place . Please check this code.