Samsung Electronics interview question

algorithm/CS based problem