Maples Group interview question

sorting the array and data structures