Amazon Interview Question for Software Engineer / Developers






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

this is mine: O(n) and in-place:
step1: reverse it;
step2: deal with it word by word;
time: O(n)

void mfunc(char *s, int size){
int ms=0, md=size-2;
char mc;
while(ms<md){
mc=s[ms];
s[ms]=s[md];
s[md]=mc;
ms++;
md--;
}
ms=0;
md=size-2;
int mstart, mend;
while(1){
while((ms<=md)&&(s[ms]==’ ‘))ms++;
if(ms>md)break;
mstart=ms;
while((ms<=md)&&(s[ms]!=’ ‘))ms++;
mend=ms-1;
while(mstart<mend){
mc=s[mstart];
s[mstart]=s[mend];
s[mend]=mc;
mstart++;
mend--;
}
}
}

- xiaobo8204 August 26, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Keep each word in node of a linked list.
Reverse the linked list.

- Anonymous October 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i have seen this question for several times in this forum.
a good solution:
reverse whole string,
then reverse each word in the string.

e.x: "how are you"
step 1: "how are you" --> "uoy era woh"
step 2: "uoy era woh" --> "you are how"

- bbs59 July 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

String src = "How are you";
Stack<String> stk = new Stack<String>();
String[] split = src.split(" ");
for (int j = 0; j < split.length; j++) {
	stk.push(split[j]);
}
		
for(String s: stk){
	System.out.println(s);
}

- Kar January 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if you don't have puzzles so why you invest your site give me a answer right now?

- radhika June 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if you don't have puzzles so why you invest your site give me a answer right now?

- radhika June 29, 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