Globant interview question

Algorithm had to be at worst N Log N time and spatial complexity.