Amazon Interview Question for Software Engineer / Developers


Team: RCX
Country: United States
Interview Type: In-Person




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

I try to make the design as simple as possible. I assumed:
1. we don't care about who has which seat, we just care about the available seats.
2. There is no need to write the part that handles user chooses a seat or user pays for the seat.

class Seat{
	int row;
	int col;
	//setters,getters
}

/*General info about theatre*/
class Theatre{
	HashSet<Seat> availableSeats;
	String theatreName;
	String theatreAddress;
	//other theatre info + setters,getters
}


/*general info about the movie*/
class MovieInfo{
	String name;
	String description;
	List<String> actors;
	//other info + setters,getters
}


/*a class that handles ticket management for a specific movie in a specific theatre for a show time*/
class MovieTicket{
	Theatre theatre;
	Date showTime;
	MovieInfo movieInfo;

	HashSet<Seat> getAvailableSeats(){
		return theatre.getAvailableSeats();
	}

	boolean synchronized commitToBuy(Seat seat){
		 if(theatre.getAvailableSeats().contains(seat)){
			theatre.getAvailableSeats().remove(seat)
			return true;
		}
	return false;
	}
}

To make it faster, one possible way is to put MovieTicket object in an LRU cache to make sure that hot movies (like a newly released movie at the weekend) can be retrieved very fast. If the MovieTicket object doesn't exist in the cache, we have to create one from our DB.

- Pooyo May 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can create a HashMap which stores movie name as key and another HashMap as value.

HashMap<String, HashMap> map;

Now this HashMap<TicketCat, Number Of Tickets remaining> where TicketCat could be platinum, Gold, Silver.

So this way you could be able to allocate tickets faster.

- sanjeev January 02, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it is necessary to keep a heap for top selling movies.

- Scooby September 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I try to make the design as simple as possible. I assumed:
1. we don't care about who has which seat, we just care about the available seats.
2. There is no need to write the part that handles user chooses a seat or user pays for the seat.

class Seat{
	int row;
	int col;
	//setters,getters
}

/*General info about theatre*/
class Theatre{
	HashSet<Seat> availableSeats;
	String theatreName;
	String theatreAddress;
	//other theatre info + setters,getters
}


/*general info about the movie
class MovieInfo{
	String name;
	String description;
	List<String> actors;
	//other info + setters,getters
}


/*a class that handles ticket management for a specific movie in a specific theatre for a show time*/
class MovieTicket{
	Theatre theatre;
	Date showTime;
	MovieInfo movieInfo;

	HashSet<Seat> getAvailableSeats(){
		return theatre.getAvailableSeats();
	}

	boolean synchronized commitToBuy(Seat seat){
		 if(theatre.getAvailableSeats().contains(seat)){
			theatre.getAvailableSeats().remove(seat)
			return true;
		}
	return false;
	}
}

To make it faster, one possible way is to put MovieTicket object in an LRU cache to make sure that hot movies (like a newly released movie at the weekend) can be retrieved very fast. If the MovieTicket object doesn't exist in the cache, we have to create one from our DB.

- Pooyo May 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

hai i am intrest design online tickets system help me
kiranygl@gmail.com

- sankar reddy January 30, 2016 | 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