Codility Exercise