a new solution with two pointers