Two Pointers Quiz
Editorial
Eleven questions across the four Two Pointers lessons: which kind of two pointers a task needs, which pointer moves, how counting and duplicates work, and what a small bug returns. Pick an answer to see whether it's right and why. Nothing is saved, so you can take it again.
If one trips you up, its lesson is Introduction to Two Pointers, 3Sum, 4Sum and Counting Pairs with Two Pointers, Same-Direction Two Pointers: Changing an Array in Place or Two Pointers on Two Arrays or Strings.
Quiz
1 / 11Multiple choice
Find two numbers in a sorted array that add up to a target. Which kind of two pointers fits?
Multiple choice
Delete every 0 from an array in place, keeping the other numbers in their order. Which kind of two pointers fits?
Multiple choice
Can
"ace" be made from "abcde" by deleting letters? Which kind of two pointers checks it?Multiple choice
[1, 4, 6, 9, 12] with target 15. The pointers sit on 4 and 12, and 4 + 12 = 16. Which pointer moves?Multiple choice
Two Sum on an unsorted array has to return the original positions of the pair. What's the right tool?
Multiple choice
How many triplets does 3Sum return for
[-1, -1, -1, 2]?Multiple choice
Counting pairs with a sum below 7 in
[1, 2, 3, 5, 6]: whenever the sum is small enough, the scan adds right − left and moves left. What total does it reach?Multiple choice
In Sort Colors,
nums[mid] is 0. What happens?Multiple choice
A Remove Duplicates solution keeps
write as the index of the last number it kept, and returns write. What does it return for [1, 1, 2]?Multiple choice
Merging
nums2 = [2, 5] into nums1 = [1, 3, 6, 0, 0] (m = 3) from the back. What is written first, and where?Multiple choice
In Backspace String Compare, which letters of
"ab##c" are left after the backspaces?