Two pointers interview questions

Pointers from both ends of sorted data, read and write pointers for in-place edits, and merging sorted sequences, with the reasoning that makes them correct.

5 quick facts

– interview-ready · 12 questions in this topic

– of 12 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. Do two sorted prices add up to a target?Predict
  2. Push the empty parking slots to the endSpot the bug
  3. Does a banner read the same both ways?Predict
  4. Merge two sorted shelves into oneFill the blank
  5. Remove repeated readings from a sorted log in placePredict
  6. Count weight triples that stay under a limitPredict
  7. Squared deviations in sorted orderPick the fix
  8. Is a short route hidden inside a long one?Predict
  1. Sort a tray of three token colours in one passSpot the bug
  2. When do two pointers work, and why?Pick the fix
  3. Same-direction vs opposite-end pointersPredict
  4. In place or a new list: what the interviewer meansPredict

Practise this topic

Flashcards · 22

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 12 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Fix this PR · 2 reviews

Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license