Saved Bookmarks
| 1. |
You Have Got 1 Million Parking Slots. At A Time A Parking Slot Can Be Free Or Not. To Get Next Slot Easily Which Data Structure To Implement? |
|
Answer» Use Stack. If you use Stack, we can just GET the NEXT slot by using stack.Pop() If you use LIST, we have to iterate through all list and check the status and RETRIEVE. So stack would be advantageous. Use Stack. If you use Stack, we can just get the next slot by using stack.Pop() If you use List, we have to iterate through all list and check the status and retrieve. So stack would be advantageous. |
|