Coveo Solutions interview question

Leetcode question with pointers and space time complexity