Amazon Interview Question for Software Engineer / Developers






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

Use suffix trees.

- PP May 08, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

no don't use suffix trees. If you do explain how.

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

The basic idea is store (begin_pos, end_pos, length) as current longest palindrome seen so far and process char by char.
Also need to store the length of palindrome that ends just before the char to be processed, let's say leng_temp. When fetching next char:
Say the next char is s[i].
If i==end_pos+1 so I can check whether s[i]==s[begin_pos-1], if yes I can upgrade current longest palindrome to (begin_pos-1, end_pos+1, length+2).
If i!=end_pos+1 then we need to check whether s[i]==s[i-leng_temp-1] if positive the upgrade leng_temp, and if leng_temp>=length, update (begin_pos, end_pos, length) accordingly.
Note that I only write out some general idea, and there're some special cases need to be handle such as if the palindrome are composed with same char, then not only need to check begin_pos-1 also need to check begin_pos so on and so forth.
But basicly such algorithm should run in linear tim.e

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

its soo easy to do using O(n*2) algo

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

Reverse the string and looking for the longest common consecutive sequence of the reversed string and the original string. Time complexity is O(n).

- ngh July 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 0 vote

I think this can be done in O(n) by simply process the string char by char from begin to end.

- scott October 19, 2008 | 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