Why in one test case i am getting a runtime error in converting a string to integer recursively?

Viewed 16

Here is my code

import java.lang.String;

public class solution {

    public static int convertStringToInt(String input){
        // Write your code here
        
        if(input.charAt(0)=='0')
        {
             return convertStringToInt(input.substring(1));
        }
        
        return Integer.valueOf(input.substring(0));    
    }
}
0 Answers
Related