Sumo Logic interview question

Complete Codility challenge