Two Pointers Algorithm Python