Amazon Interview Question Software Engineer / Developers
0of 0 votesDesign a parking lot where cars and motorcycles can be parked.
Country: United States
Interview Type: Phone Interview
Some questions needs to be asked --- Are both expected to consume the same amount of space? (It may be desirable that a different parking lot or a different level or a selected area be designated for Motorcycle parking).
Other important point that needs consideration are duration of parking and payment, Type of parking spot (Regular, Valet or for Handicapped - More classes can be added).

1. Create a class for the vehicle:
public class vehicle{ private String vehicle_num; private String OwnerName; private long ownerCellno; private String inTime; private String outTime; //create the getters and setters for the above fields }2. Create a HashMap:
- A on January 10, 2013 Edit | Flag ReplyHashMap<Vehicle, Integer> parkDetail = new HashMap<Vehicle, Integer>();
where the second Integer field is the parkingspot ID.
//This HashMap will keep the details of the occupied parking slots.
3. Create a Queue of Integer which will be used to track the free parking spots, when a parking spot gets free...add it to the queue....If a new vehicle has come den remove the corresponding entry from this queue and add it to hashMap.
For 4 wheeler and 2 wheeler, we can maintain two copies of HashMap and Queue as there will be different parking spots for both.