Problem Brief
Assign Locker
INTERNOA
See Google online assessment and hiring insights
An automatic locker system is introduced into the changing room. When a customer visits the changing room, the system works as follows:
The locker numbers start from 1. At the beginning of the day, all lockers are empty. The changing room is visited N times. Which locker is assigned to a customer for the last time?
⊹ ࣪ Credit to 𓆝⋆。˚ 77﹏𓊝﹏𓂁﹏⊹ ࣪ ˖
1Example 1
Input
clients = ["Alice", "Eve", "Bob", "Eve", "Carl", "Alice"]
Output
2
Explanation
- Locker 1 is assigned to Alice;
- Locker 2 is assigned to Eve;
- Locker 3 is assigned to Bob;
- Eve releases locker 2;
- Locker 2 is assigned to Carl;
- Alice releases locker 1.
The last assigned locker is locker 2, so the function should return 2.