Two pointers is a method for iterating over a linear collection, such as array list and string, by maintaining two indices instead of one to reduce the time complexity of the solution

Let's see a specific example

The 2Sum Problem

Given an array of integers A[N] and an integer number targetSum

Find if existing in A two integers A[i] and A[j] such that A[i] + A[j] = targetSum

Two pointers approach