Lime Interview Question

A problem on 2 pointers on hacker rank