Interview Question

Software QA Engineer Interview(Student Candidate)

read in a string and output it backwards

Answer

Interview Answer

3 Answers

0

i said push each letter into a stack then pop and output repeatedly until there were no more letters

Interview Candidate on Jun 4, 2011
0

void printrev(const char* str)
{
    if(*str=='\0')
        return;
    printrev(str + 1);
    cout<<*str;
}

Anonymous on Dec 13, 2011
0

public void (String input) {
if (input == null || input.length == 0)
return;

for (int i = input.length-1; i >= 0; i--) {
System.out.print(input.charAt(i));
}

System.out.println();
}

BCM on Feb 14, 2013

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up