Microsoft interview question

A problem based on 2 pointers