Amazon Interview Question for Software Engineer / Developers


Country: United States




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

By Fermat's last theorem, there are no positive integral solutions to: x^n + y^n = z^n for n>2. Hence, there exist solutions only of the form (0,a,a) and (a,0,a), hence there are totally (2*N + 1) solutions since 'a' belongs to [0,N].

- Anonymous March 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think u mean the number of solutions is 3*N + 1.
We have 3 ways to choose 1 out of a,b and c as 0 and N values for the other two => 3*N. Furthermore, + 1 because of the solution triplet (0,0,0). :)

- manish.mng March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@manish...
i think its only 2*n+1 sols... cos when z=0, then x and y has to be 0, which causes the +1..

correct me if i am wrong...

- ashish March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Are we talking about the numbers a, b , c as whole numbers.??

- Mohit March 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

Here is my answer to this question. The time complexity of my implementation is O(logN * logN). Can we do better?

basicalgos.blogspot.com/2012/03/30-computer-all-possible-solution-of.html

- Andy March 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

At the risk of sounding a little rude, no one is interested in seeing code first when they seek a solution to a problem.

Can you please explain the logic, then the code would make a little more sense. Thank you.

- Ananth March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Andy, The solution in ur blog is O(n*n). Morevover, Anonymous above is right.. As per Fermat's Last Theorem, solution for a^n + b^n = c^n doesn't exist for n>2. So no point writing that code..

- Manish March 25, 2012 | Flag


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