Codility Exam Solutions - Java