Gap Inc. interview question

one of the coding question was solved by 2 pointer technique