Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

This is the one when we don't know the lenght.

public String recursiveReverseString(String s) {
if (s.length() <= 1)
return s;
else
return recursiveReverseString(s.substring(1)) + s.charAt(0);
}

- Pedro November 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is this C style null terminated string ?
Please clarify the question.

- Anonymous November 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a string is always ended by '/0' we can use this end of string character to reverse string.

- sushantmax88 November 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Just use exclusive or to reverse the string..

- sur November 03, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

can u kindly explain how to do this using XOR?

regards,
raju

- raju November 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Add it to the string buffer and use reverse function in java

- Yomi November 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@pedro
Why dont you make a new string and than iterate the original string and start inserting characters in the beginning of new string.
It would be better.

And finding sub string also requires the length of string.
And its also O(n)

I guess we need to do it in place.

- nitin November 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@nitin

your idea sounds good.

- Pedro November 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

char token;
int temp=0;
int i;

while(str[temp]!='\0')
{
token = str[temp+1];

- Anonymous December 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use a stack, keep pushing until you encounter a '\0'. once there pop until the stack is empty and overwrite the original string (if you dont need it)

- veeru January 12, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More