SOUTHWORKS Interview Question

Code challenge in codility, find bugs