Skip to content

Commit f98984e

Browse files
authored
Update String to Integer
1 parent 791394d commit f98984e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Course 2 - Data Structures in JAVA/Recursion Assignment/String to Integer

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ Sample Output 2 :
2323
12567
2424
*/
2525

26+
public class solution {
27+
28+
public static int convertStringToInt(String input){
29+
// Write your code here
30+
if (input.length()==0)
31+
{
32+
return 0;
33+
}
34+
int smallOutput=convertStringToInt(input.substring(0,input.length()-1));
35+
int val=(int)input.charAt(input.length()-1);
36+
val=(val-48);
37+
//System.out.println(val);
38+
return (val)+(smallOutput*10);
39+
40+
}
41+
}

0 commit comments

Comments
 (0)