Samsung Electronics interview question

Reader Writer Problem