🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.O(n²) time, O(1) space
  2. B.O(n) time, O(1) space
  3. C.O(n) time, O(n) space
  4. 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 →