Amazon Interview Question for Software Engineer / Developers






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

it looks like we need to use inheritance to acheive this, where in you have a superclass with generic functionality and a long list of subclassess overriding the generic methods of super class to provide specific behaviour.

- Raghu December 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Bad bad design.. .n bad thinking as well.

- Anonymous January 31, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can have a an interface called ICard

public interface ICard extends Comparable
{

public static final int SPADES = 0;
public static final int HEARTS = 1;
public static final int DIAMONDS = 2;
public static final int CLUBS = 3;

public int getSuit();
public int getRank();

}

also we can have a deck class

public class Deck implements Iterator
{

	private ArrayList myCardList;
	private int myIndex;


	public Deck()
	{
		myCardList = new ArrayList();
		for(int suit = ICard.SPADES; suit <= ICard.CLUBS; suit++)
		{
			for (int rank = 1; rank <= 13; rank++)
			{
			myCardList.add(new Card(suit,rank));
			}
		}

		shuffle();
	}

	private void shuffle()
	{
		Collections.shuffle(myCardList);
		myIndex = 0;
	}

	public boolean hasNext()
	{
		return myIndex < myCardList.size();
	}
	
	public Object next() 
	{
		ICard card = (ICard) myCardList.get(myIndex);
		myIndex++;
		return card;
	}
	
	public void remove() 
	{
		throw new UnsupportedOperationException();
	}
}

- ketz January 10, 2011 | 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