Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

1. when a product is added to system it would generate an event.
2. Customer notification module will register and receive this event.
3. Customer wishlist table will list of customer id with product id they wish for.
4. The event processing will look for customer list for the product id, event is generated for.
5. It would notify those customers.
6. and remove them from the wishlist table.

- raj May 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 vote

it is a pure example of "Observer" pattern. Customer will be register for with producer for notifications.
stock would be observable entiry.
Observer will notify all registered customers about the stock availability.

- pa1 May 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

java-x.blogspot.kr/2007/01/implementing-observer-pattern-in-java.html

- Anonymous June 10, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 3 vote

import java.util.*;


public class Stock {

public static void inStock(int productId){

int id = productId;
HashMap<Integer,Integer> stock = new HashMap<Integer, Integer>();

stock.put(101,5);
stock.put(102,6);
stock.put(103,7);
stock.put(104,8);
stock.put(105,9);


int value = stock.get(id);

if(value==0){
System.out.println(" stock of the product is null");
}


else if( value>0 && value<25) {

System.out.println(" stock of the product going to finish but above 0 and less than 25");

}

else {

System.out.println(" we have a sufficient");

}
}
public static void main(String args[]){
inStock(102);




}










}

- naveengarg2k5 July 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

It is just like a producer and consumer problem,
store all customers id's in an array, if products are available, corresponding single sent to customets (like consumer in thread progaming)

- abcde April 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Store user and product withslist information in table or data structure. When new stock comes in, do a join on the product id and get the list of customers with the corresponding product wish list and send a notification to them..


just another thought, is this simple, or there is something underthe hood for the problem

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

here we have a class Store which having list of product and its availability if any customer want any product it is there give him other wise register him for notification for particular product notification list when item is added notify all customer who is available in notification list and remove customer from that notification list."observer pattern"

- mm. August 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

here we have a class Store which having list of product and its availability if any customer want any product it is there give him other wise register him for notification for particular product notification list when item is added notify all customer who is available in notification list and remove customer from that notification list."observer pattern"

- manish August 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Observer pattern.

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

We can utilize 4 main classes:

class User {
	String name;
	String email;
}

class Product {
	String name;
	int       id;
	int       amount;
	double price;
}

class Store {
	ArrayList<Product> inStock;
	ArrayList<Product> outStock;
	
	void add(Product) {...}       //adds new product to inStock
	void remove(Product) {...} //removes product from inStock and outStock
	void update(Product) {...}  //updates the product information such as 
                                                        //price/amount and sends notification when amount 
                                                        //change
}

class NotificationMgr {
	Hashmap<int, LinkedList<User>> waitingList;
	void register(User, Products[]);      //user registers for notifications
	void unregister(User, Products[]);  //user deregisters for notifications
               
              /*
	Use the Observer design pattern to receive the notifications when a product
               is moved from the outStock to inStock and send the notification to all registered
               users
              */
}

- YD September 11, 2013 | 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