I got this interview question during my onsite.
I didn't have to code anything it was more like a brain teaser and I had to exaplain various approaches. The interviewer guided me and said that there was no one specific answer but he wanted to see if I could explain the various tradeoffs and come up with a solution which was the most ideal.
Imagine a huge castle. There are multiple entrances. These lead to rooms which have doors which lead to more rooms and more doors.
Every door has a unique id.
Now we want to block certain doors at night. This is where the magic part of the door comes in.
There is a list where we can add the id of the door. If the id of that door is added to this list, that door gets locked at night. Nobody can get in through.
However there is a drawback. Repairs are regularly carried out and the doors are constantly being upgraded. If we replace a door, and the new door's id isn't added to the list, it will stay unlocked.
There is no communication between the workers who replace doors and the magician who maintains the list.
There is no marking on the door to indicate that it is a locked door.
How can we design a system where by the locked doors don't get accidently replaced?