Algorithms and Data Structures · Junior · Question 42 of 75
What is the "two pointers" technique?
- ✓Correct answer: Moving two indices through the data by a rule
- 2Storing every element twice for faster access
- 3Running two copies of an algorithm in parallel threads
Explanation
Two indices move through the array instead of nested loops, which often turns O(n²) into O(n). Classic uses: checking a palindrome from both ends, merging two sorted arrays, finding a pair with a given sum in a sorted array.