Getting wrong answer with String as input

Used String to take input and traversed the string to get the int value and then calculated output. is this the correct way to handle this problem.

depends on length of string id length <=18 its ok.

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.