SAP interview question

leetcode medium two pointer question