In the sorted array [1, 2, 5, 9], the target sum is 10. The pointers initially select the first and last elements. What is their sum?
Answer & explanation
Answer: 10
The initial pair contains n and n + 8, which already equals the target.
Practice two pointers with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
Answer: 10
The initial pair contains n and n + 8, which already equals the target.