Alibaba Group interview question

Two pointers leetcode hard with.