Two Pointer Approach In Js