Some cases are not clear

Don’t you think there must be one if condition to check if I get a negative length I will not call . https://ide.codingblocks.com/s/286992 see line no. 12.

Yes…if it is mentioned in the constraints of the question that it can be negative, then you must add that case.
Here we were assuming that it would never be negative

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.