← Two Pointers Quiz: all 8 questions
Two Pointers Quiz · Question 3 of 8
What is the time and extra space of two-pointer Two Sum on a sorted array?
What is the time and extra space of two-pointer Two Sum on a sorted array?
- A.O(n²) time, O(1) space
- B.O(n) time, O(1) space
- C.O(n) time, O(n) space
- D.O(log n) time, O(1) space
Answer & explanation
Correct answer: O(n) time, O(1) space
Each step moves one pointer, so at most n steps, with only two index variables.
Can you get the rest right without peeking?
Take the timed Two Pointers Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →