Choosing a Pattern
Choosing a pattern: reading the cues in a coding problem's wording to pick the pattern that fits, and telling a real cue from a keyword.
Choosing a pattern is deciding which of the fourteen patterns in this subject a new problem calls for, by testing the problem for the properties each pattern needs rather than matching words in its statement. It matters because an interview problem never says which pattern it wants, and a pattern picked from a keyword gives a fast answer to the wrong question. The topic opens on one decision that reads the input's structure first, then the shape of the question, then what the values allow, with each branch leading to the pattern's own topic. Two examples apply it: the closest departures on two sorted timetables, where three alternatives are weighed, and a delivery roster whose shifts hide the intervals the question needs. A comparison sets the four array patterns most often confused side by side, a gotcha shows the word "largest" picking a heap for a problem about consecutive days, and an exercise asks for the pattern behind five problems before the recap.
Contents
7 cardsnot started