Amazon Interview Question for Software Engineer / Developers






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

String toPostfix(String infixStr){
		
	if( infixStr == null ){
		throw new IllegalArgumentException("NULL str passed");
	}
		
	final StringBuilder postfixBuf = new StringBuilder( infixStr.length() );		
	final Deque<Character> operatorsStack = new LinkedList<Character>();
		
	for( char ch : infixStr.toCharArray() ){			
				
		// operator found				
		if( isOperator(ch) ){		
					
			while( ! operatorsStack.isEmpty() ){	
					
				char prevOperator = operatorsStack.pop();							
					
				if( compareOperators(prevOperator, ch ) < 0 ){
					operatorsStack.push(prevOperator);
					break;
				}
					
				postfixBuf.append( prevOperator );
			}
			
			operatorsStack.push(ch);
		}			
		// operand found
		else{
			postfixBuf.append( ch );
		}
	}
	
	while( ! operatorsStack.isEmpty() ){
		postfixBuf.append( operatorsStack.pop() );
	}
		
	return postfixBuf.toString();
}

- m@}{ March 30, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@m}@{ algo & explnation plz..plz plz

waiting for explaination

- raga April 06, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@m}@{ algo & explnation plz..plz plz

- raga April 01, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

make use of shuntington algorithm.
you see a operand you pass it to output.
you see a operator:
check the priority of operator on top of stack:
if higher priority push it to the stack
else (lower or equal priority) pop the operators until the one with lower priority is found
repeat till the end of the infix expression.

- Anonymous April 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

http :// scriptasylum . com/ tutorials/ infix_postfix/ algorithms/ infix-postfix/ index. htm

- smffap December 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi there,
I gave amazon's written test for SDE, had similar exp. There were 3 questions I gave best solutions for 2 , still couldn't qualify. I doubt they look for solution which they already know. This is embarrassing!

- amit September 08, 2012 | 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