Cisco Systems Interview Question
Country: India
Interview Type: In-Person
First i would think of what operation will be done in a car parking:
--- add a car in the first empty parking space
--- delete a car from a given index in the parking lot
--- check if there are any empty spaces available
I would use a hasmap to map the parking spot to the car parked on it.
I would use another hashmap to keep track of te empty slots in order.
This does not make any sense for me. The heap allows to get the smallest or the biggest element in constant time after the heap is created in linear time... but when a new car comes we have to rearrange the heap it depens from the value... I do not know but to represent parking I thin the best would be just an array of spaces
Because, heap's space and time complexities are very efficient. Just browse through the Wiki for Heap datastructure. If you can customize your functions then time complexity can be reduced polynomially.
I would use... wait. What are the scenarios?
- Anonymous December 22, 2012