Amazon Interview Question
Software Engineer / DevelopersI dont know if you meant we should also avoid the Math and the String library functions -
String x = "121";
int res= 0;
for(int i=0;i<x.length();++i){
int y = (int)(x.charAt(i)-'0');
res= (res*10)+y;
}
we need to parse the string in the reverse order and iterate from all the characters and subtract 48 from each character and build the required number.
- Anonymous August 08, 2010