Multiple pointers algorithm pattern
Using the multiple pointers pattern by creating pointers or values that correspond to an index or position and move towards the start end or middle based on a condition can help you efficiently solve problems with minimal space complexity.
usually, you use it if you’re searching for a pair of values or a condition, you start at two places and you work your way to each other in order to reach a middle value.
an example of this is if you were asked to find a pair of numbers that add up to something in particular. assuming the array of integers that you’re given is sorted, you can start a pointer at index 0 and -1, from here you could iterate each index on pointer 1 until you reach the second pointer, from there you can iterate down on pointer 2 until you get the pair that returns the sum you’re looking for if there is no answer for this problem you can return null.