Amazon Interview Question Software Engineer / Developers


Country: United States
Interview Type: Phone Interview


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

for the poker or card game:-
we have to make such decision,
for deck part():_
1.deck is shuffled
2.card are dealt one at a time from the deck and added to the player's hand

for card parts:-
1.cards can be removed from hands
2.new card can be added

so basically it comes in our mind that class would be
game,
player,
hands,
card,
deck,
value and
suit

now here i am going to explain how to design some class according to our analytical knowledge;

let i am going to design class for say deck class and hands

for deck class :- the question comes whether it is shuffled or whether its dealt.
so here ,obviously method would be shuffle() and dealcard()

we will think for hands in same fashion.
that is for hands class ,we have to think about card is added or removed.
so clearly here method becomes addcard() and removecard()

now here when we are dealing with remove card then the question comes,how we are going to remove or add from deck of cards.

and according to our analytics we will have to add cardleft() type method for deck class

so it would be like

class deck{
private:
int a[52];
.....
.....
public:
shuffle();
dealcard();
cardleft();
}

and for hands class
class hand{
private:
.........
........
public:
addcards();
getcardcount();
rearrange();
removecard();
discard();
}

blah bla......

- shishirvicto on November 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

the explanation for cardleft() should be there.
and another function returncard(Card c) is missing.
As, deck is holding the list of cards, the card class details are to be added like

Class Card{
	private int suite;
	private int num;
	public Card(int suite, int num){
		this.suite=suite; this.num=num;
	}    
}

- spiderman on August 19, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through 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