Amazon Interview Question for SDE-2s


Team: Online Fraud Prevention
Country: United States
Interview Type: Phone Interview




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

I am just curious... what answer did u give and what kind of design patterns did u use ?

- king July 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

From your profile you seem to be better placed to answer such questions as Microsoft is also known for asking such open ended questions.
Can you please suggest how would you approach this design problem.

- I.mFirst July 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Every user would be given default space during signup , and on every referral he would be given bonus space.The information related to bonus space can be stored in a map.
This map contains ReferredUser and bonus space .
To get total space of a user we should add default space and total free space acquired by referral.

class user
{
   Space space;
   ....
   ....
}

Class Space
{
    int initialSpace; //the default space that the user gets on signup
    Map ReferredUsers<User,int>;//Map of referred user and free space aquired as referral bonus
    
    TotalSpace()
    {
        for(each referred_user in ReferredUserList)
              tempspace = tempspace + referred_user.second ; //get the free space from map
         
         return tempspace + initialSpace;
    }
....

- BJ August 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

First we have the user - this is for an existing user

class User {
	//Basic information
	int      id;
	String name;
	String email;
	 
	/* total space -- need to add more information about the account 
          but this is enough for this question (available, max, etc)
        */
	int space;
	int add_space(int amount) {...}
}

Second we need something to represent an invitation

class Invite {
      String email; //email of the person being invited
      int    id;    //id of the user who invited him   
      
      Date   sent_date; //These 2 will allow the system to
      boolean status;   //track the invite status and send
                        //automatic reminders
}

Third there needs to be a system to manage all of this

class Dropbox {
      map<int, User> users;   //all the users
      ArrayList<Invite> invites; //all invitations sent

      //sends an invite to the email inputed by the user
      //and adds a new Invite to the invites ArrayList
      void sendInvite(User from, String to) {...}

      //When the invited party accepts the invitation
      //this function is triggered and: 
      //1. Creates a new User and adds to users.
      //2. Finds the user that invited him from the invites list
      //   (according to email and id) and calls add_space
      void accept(String email) {...}          
}

- YD September 09, 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