P-7.3 The Patterns Most Questions Use
You recognise the four shapes that cover a large share of screening questions, and you can name which one a new question wants before you start writing.
Screening questions are drawn from a small set of shapes, and recognising the shape is most of the work. Four cover a large share of what a first round asks, and they are worth knowing by the names people use for them: two pointers, a sliding window, counting with a hash table, and running totals. This is recognition practice rather than new theory: the structures themselves are taught in the data structures module and are not repeated here. What is added is the habit of naming the shape first and writing second, which is what turns a twenty-minute question into a five-minute one.
Work through these
Two pointers: one index from each end, or one chasing the other
A sorted-array question that looks like it needs two nested loops usually needs two indexes that each move once. The shape turns quadratic work into a single pass, and recognising it is the whole trick.
Algorithms, 4th Edition — companion site · ReferenceA sliding window: keep a range and move its edges instead of rebuilding it
Questions about the best run of consecutive items are window questions. Adding the item that enters and removing the item that leaves is what keeps the cost linear instead of quadratic.
Counting with a hash table, and naming what it costs in memory
Anything phrased as most frequent, first repeated, or seen before is a counting question. The table buys average constant-time lookup, and the memory it spends is the trade you should say out loud.
NPTEL: Programming, Data Structures and Algorithms using Python · CourseRunning totals, so a range sum stops being a loop
Precomputing the total from the start of the array lets any range be answered with one subtraction. It is the cheapest example of paying once so that many later questions cost nothing.
Take ten unseen questions and name the shape of each one before writing any code
The exercise is deliberate recognition with no solutions written. Naming the shape first is the habit that makes a round feel shorter than its clock, and it is trainable in an afternoon.
Sign in to keep your progress.
Free resources
We haven't checked most of these for screen reader use yet.
Links last checked 31 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.