fork download
  1.  
  2. public class solution {
  3.  
  4. public static int convertStringToInt(String input){
  5.  
  6.  
  7. return convertStringToIntHelper(input, 0, 0);
  8. }
  9.  
  10. public static int convertStringToIntHelper(String input, int idx, int ans){
  11.  
  12. if (idx == input.length()-1) {
  13.  
  14. int val = input.charAt(idx) - '0';
  15. ans = ans * 10 + val;
  16.  
  17. return ans;
  18. }
  19.  
  20. int val = input.charAt(idx) - '0';
  21.  
  22. ans = ans * 10 + val;
  23.  
  24. return convertStringToIntHelper(input, idx+1, ans);
  25. }
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class solution is public, should be declared in a file named solution.java
public class solution {
       ^
1 error
stdout
Standard output is empty