Codility Exam Solutions Java