A locker room tracks which locker ids are currently registered as in use. Starting from an empty registry, it processes q operations, each one of:
ADD x — register locker id x. If it is already registered, nothing changes.REMOVE x — unregister locker id x. If it is not registered, nothing changes.HAS x — report whether locker id x is currently registered.Line 1: an integer q.
Next q lines: one operation each.
For every HAS operation, in order, print 1 if the id is currently registered, otherwise 0.
Example 1
Input
5 ADD 3 HAS 3 REMOVE 3 HAS 3 ADD 3
Expected
1 0
Explanation
After ADD 3, HAS 3 prints 1. After REMOVE 3, HAS 3 prints 0.
Example 2
Input
4 HAS 7 ADD 7 ADD 7 HAS 7
Expected
0 1
Explanation
Initially 7 is absent so HAS 7 prints 0. After registering it (twice; the second is a no-op), HAS 7 prints 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →