Sumo Logic Interview Question

Complete Codility challenge