Amazon Interview Question for Software Engineer / Developers






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

can u explain the question bit more?

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

the question is to write psuedo code for creating a deck of cards. most decks have a 52 cards with 13 cards per suite. just add the two joker cards after the deck is created instead of shuffling the deck. If you google for create a deck of cards program you should be able to find many solutions

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

Quick question. Does the deck have to be shuffled ?
If not then the question is trivial. First create 13 cards of heart, then spade, then diamonds and then clubs.
If the initial deck itself is shuffled, then it is a bit tricky. I would suggest creating the normal deck before then use some kind of bit map to randomly generate cards out of the deck

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

the interviewer didn't say anything about shuffling. they just wanted the candidate to write pusedo code for creating the deck of cards

- biggied88 March 09, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

exactly!! but instead of creating thirteen for each design which will make 13*4 loops, we can create 4 cards of each design per value which would make 13 iterations.

- clrs March 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

foreach a (1..13)
  foreach b (1..4)
    doSomething(a, b)

Has the same complexity as

foreach a (1..13)
  doSomething(a, 1);
  doSomething(a, 2);
  doSomething(a, 3);
  doSomething(a, 4);

- But... March 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

clrs the logic is correct but backwards, it should be:


int rank = 13;
int suite = 4;
foreach(0...suite){
//add new suite
foreach(0...rank){
//add new card
}
}
add two jokers

- biggied88 March 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

this is more efficent becuase the main for loop will cycle only 4 times

plus i made a little error in my psuedo code it should be:

Card[] deck;
int rank = 13;
int suite = 4;
String
foreach(0 <= suite){
foreach(0 <=rank){
//in card class add the suite and rank string value
deck[number of cards] = new Card(suite, rank);
}
}
add two jokers

- biggied88 March 15, 2010 | 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