First implementation, use two pointers