Google Interview Question
Software EngineersCountry: United States
Interview Type: In-Person
Create a hash table, go through each element and:
1) if starts with 'E' insert if such element isn't there, otherwise return invalid error
2) if starts with 'L' remove element with a key 'L {number}', otherwise return invalid error
Finally, if there are any keys left, that means building isn't empty, return invalid list error
In an interview with this simple semi-open question, you'd better mention as much detail as possible.
Marcello thought about three corner cases, while there are more to mention
- The room should not be infinite large, ask the interviewer for a maximum size and check the size when someone enters to make sure there isn't too many people in the same room.
- What if one of the person in the room throw his badge out of window and someone else get it, then enter the room with the badge, it will simply trigger invalid log in the above algorithm. It is better to ask then simply making default assumption that there is no such a case. Because in reality, it is totally possible.
In an interview with this simple semi-open question, you'd better mention as much detail as possible.
You thought about three corner cases, while there are more to mention
- The room should not be infinite large, ask the interviewer for a maximum size and check the size when someone enters to make sure there isn't too many people in the same room.
- What if one of the person in the room throw his badge out of window and someone else get it, then enter the room with the badge, it will simply trigger invalid log in the above algorithm. It is better to ask then simply making default assumption that there is no such a case. Because in reality, it is totally possible.
- seriyvolk83 April 09, 2017