What is the Two Pointers Technique:
uses two index variables to traverse a linear data structure—like an array, string, or linked list—to solve problems efficiently without nested loops.
Why Use it ?
Time Efficiency: It often reduces time complexity from O(n²) (using nested loops) down to linear time O(n).
Space Efficiency: It typically requires constant space O(1) because it only tracks a few indices.
Whats Patterns of 2 Pointers
Pattern 1 (Variable_Size)
1.1 Opposite Direction (Converging Pointers): One pointer starts at the beginning (left = 0) and the other at the end (right = n — 1). They move toward each other until they meet. Best Used For: Sorted arrays, pair sum problems (ex: Two Sum on sorted input), or checking palindromes.



