Amazon Interview Question for Software Engineer / Developers






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

A generic list class with Front Back Split and Shuffle Merge may be. One can also write a shuffle function as
for i = 1 to n
swap(cards[i], cards[random(i,n)]);

- SP March 20, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

operations: shuffle, deal, and play.

so class: Card, Player, Dealer
objects: card objects, player objects, and a single dealer object.

Any improvement?

- cd April 30, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it asks about generic dec of "cards", not players.
so it would be like
deck -> suite -> cards something like that, and maybe have multi-inheri for face cards and numbered cards... perhaps.

- phi October 13, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Seems like the basic classes would be Deck and Card. I think it's a mistake to use inheritance to designate different types of card; the difference between a two of hearts and a queen of spades is nothing more than data.

For a card, we'd want an int member variable for the value (not zero-based, so it syncs with actual card numbers... one -> ace, five -> five, twelve -> queeen, etc.), and an enum for the suit. It would be trivial to check whether the card was red or black; thus, it's probably not necessary to have a member for that.

The deck class would need some sort of collection of fifty-two cards. Since this is for poker, it's probably safe to assume that we'll only draw from the top of the deck; thus, we can just keep a variable with the number of cards in the deck for use when we shuffle or something so we don't have to worry about the cards we removed, and store it in a simple array. We'd want some sort of "shuffle" method... I'm not familiar with the relative randomness of various algorithms, but what SP suggested sounds fine. We'd of course want a "draw" method that would return the top card of the deck and decrement the card count. The constructor should add all of the possible cards to the deck, but not shuffle, in case the user wants it sorted for some reason.

- Nex3 December 26, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Define Struct or a Class Cards (Holds Color, Number)
Define Class Deck add the cards for each type.

- OldGuru April 20, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What if I don't know anything about a Poker game?

- Anonymous June 17, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 0 votes

then you will not get a position in Amazon

- Anonymous November 13, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You would probably want to assign a value of 14 to the ace since in poker, ace is high and not low.

- Katy December 05, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You can ask the interviewer to explain the game to you.

- burdell August 22, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

he asked me poker game, I described blackJack :)

- Anonymous April 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

class - card,hand,deck
objects for class - suite,rank

- Anonymous January 20, 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