SOUTHWORKS interview question

Code challenge in codility, find bugs