Gap Inc. Interview Question

one of the coding question was solved by 2 pointer technique