Samsung Electronics interview question

make code review of algorithm code