How would you implement a two-pointer approach to reverse a string or find a target sum in a sorted array?