PRACTICE / UNDERSTAND / REPEAT

Data Structures & Algorithms: Two pointers

Practice two pointers with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

20 questionsAnswers explainedFree · no login
Question 1 of 20
Two pointers · MCQQuestion link ↗

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?

Choose one answer
Answer & explanation

Answer: 10

The initial pair contains n and n + 8, which already equals the target.