Agoda interview question

Leetcode question around sorting & 2 pointers