Lesson 27 of 27Practice and polish
Wrap-Up: Problem Solving
Tie the whole Problem Solving track together: one unseen problem taken from first read to tested answer and follow-ups, a mixed review, and where to go next.
You started this track by reading a problem twice and saying it back in one sentence. Since then you have learned to mine the examples and constraints for hints, climb from a brute force to a plan, talk through a full 45-minute round, decode each family of problems from one deciding clue, and practice in a way that sticks. In a real round none of these arrive one at a time. This lesson lines them up once more and then uses them together on one problem you have not seen.
The path you took
Unit 1
Read before you code
Restating, examples, constraints, wording clues, edge cases and clarifying questions turned a prompt into a precise question, ready for a plan.
Unit 2
From idea to plan
Brute force first, the bottleneck, the right structure, your language's toolkit, the pattern map and dry runs gave you a plan you trust before you code.
Unit 3
Talk it through
Narrating, getting unstuck, debugging, explaining complexity, testing and follow-ups turned a plan into a round an interviewer can score.
Unit 4
Decode by category
The deciding clues for arrays, trees and graphs, DP and greedy, backtracking and heaps, and strings, math and design sharpened the pattern map.
Unit 5
Practice and polish
Multi-part practical problems and a practice system with a mistake log made the routine fast enough to use under a clock.
How it fits together
The round: a 45-minute phone screen. The interviewer pastes this. "A print shop has a list of jobs, each a number of pages. One printer handles one job at a time and prints at a fixed speed you choose, in pages per hour. If a job finishes partway through an hour, the printer sits idle for the rest of that hour. The shop closes in h hours. What is the slowest speed that still finishes every job?" Constraints: up to 10^4 jobs, each up to 10^9 pages, and h is at least the number of jobs. Here is how the track shows up, in the order you would really use it.
Reading it. Following Reading the Problem, you read once for the story and once for the limiting words: "slowest", "every job", "idle for the rest of that hour". Stripped of the story it says: given an array of positive integers and h, find the smallest speed s such that the sum of ceil(p / s) is at most h. You say that sentence out loud.
Examples and edge cases. From Inputs, Outputs, and Examples you build your own example, [3, 6, 7, 11] with h = 8, and work it by hand. Edge Cases from Constraints turns each constraint line into a test: h equal to the number of jobs forces one hour per job, so the answer is the largest job. A single job, and pages near 10^9, go on the list too.
Asking the right question. Clarifying Questions says to ask only what changes the code. "Can one hour cover the end of one job and the start of the next?" changes everything, and the answer is no. That is why it is a ceiling per job and not one total divided by the speed.
Brute force, then the bottleneck. Brute Force First says to state it with its cost: try every speed from 1 upward and stop at the first that fits. That is up to 10^9 speeds times 10^4 jobs. Constraints Are Hints puts that against the budget of about 10^8 simple operations, so it is far too slow. Find the Bottleneck points at the outer loop: you test speeds one by one, yet a faster printer never needs more hours. The check is monotonic.
Naming the pattern. "Smallest value such that something is possible" is a phrase from Clues in the Wording, and Decoding Arrays and Strings draws exactly this contrast: you are searching an answer, not a value in the array. The Pattern Map agrees, and the value range of 10^9 confirms it. Binary search over speeds costs about 30 checks of O(n) each. No extra structure is needed, which Choosing Data Structures tells you is a fine outcome.
Planning the loop. Before coding, Dry Runs and Invariants has you state the rule: hi is always fast enough, and every speed below lo is too slow. You trace it on your example and land on 4. From Your Language's Interview Toolkit you use (p + s - 1) // s for the ceiling, which avoids float error on large numbers.
Coding and testing. You narrate as you type, as in Thinking Out Loud, then test in the three passes from Testing Your Own Solution. When you can run code, a small stress test against the brute force catches the bugs a hand trace misses:
Press Run (⌘ Enter) to see what happens.When it goes wrong. Suppose your first draft wrote lo = mid and the loop never ended. Debugging Under Pressure says to read what actually happened before rereading the code: with two values left, mid equals lo, so nothing moves. You fix that one line and run the tests again. If you had frozen earlier with no idea at all, Getting Unstuck would have told you to write the brute force, which still leaves you with working code.
Complexity and follow-ups. Explaining Complexity gives the two sentences: "About log of the largest job iterations, each a pass over n jobs, so O(n log m) time. Only a few variables, so O(1) extra space." Then Handling Follow-Up Questions takes over. "What if the jobs must stay in order across k printers?" Same check, same binary search, new feasibility function. That is Split Array Largest Sum. The Full Walkthrough is why you still have ten minutes for it.
After the round. You spent four minutes stuck on the ceiling. That goes in the mistake log from Practice That Sticks, with a redo in a week. If the next round is a practical multi-part spec instead, Multi-Part Practical Problems uses the same reading and testing habits, at the scale of a small codebase.
Notice that no lesson worked alone. The restatement exposed the ceiling, the constraints ruled out the brute force, the brute force became the test oracle, and the invariant made the loop correct on the first run.
Check yourself
Match each phrase in a prompt to the pattern it usually points to.
What does this print?
def hours(piles, speed): return sum((p + speed - 1) // speed for p in piles) print(hours([3, 6, 7, 11], 4), hours([3, 6, 7, 11], 3))
Put the stages of a 45-minute coding round in order.
- Tap the steps below in the right order.
What you can do now
- Read an unfamiliar problem and restate it precisely, with your own examples and edge cases.
- Turn the constraints into a time budget and rule algorithms in or out before you design.
- Go from a brute force to a faster plan by naming the repeated work and the structure that removes it.
- Map wording and input shape to a short list of patterns, and break a wrong guess with a counterexample.
- Run a full round out loud: narrate, recover when stuck, debug calmly, test, state complexity and answer follow-ups.
- Keep a practice system that turns each mistake into something you can redo under pressure.
That is a strong level for typical coding rounds. What it does not give you is depth on the hardest problems or speed on patterns you have not drilled. Those come from steady practice and from the courses that follow.
Mistakes that still catch people
- Solving a slightly different problem. Skimming past one limiting word like "strictly" or "contiguous". Revisit Reading the Problem and Inputs, Outputs, and Examples.
- Skipping the brute force. You lose your safety net and your test oracle. Revisit Brute Force First and Testing Your Own Solution.
- Trusting one wording clue. "Subarray" sounds like a sliding window until negatives appear. Revisit Clues in the Wording and Decoding Arrays and Strings.
- Going silent. The interviewer cannot score or help with thinking they cannot hear. Revisit Thinking Out Loud and Getting Unstuck.
- Forgetting the edges the constraints promised. Empty input, all-equal values and overflow. Revisit Edge Cases from Constraints and Constraints Are Hints.
- Grinding without redoing. Solving 200 problems once and remembering few. Revisit Practice That Sticks.
Where to go next
The next course on the site is Design & Architecture, which moves from single functions to how real codebases are shaped. That is also where multi-part practical rounds go next. After it, System Design covers the other big interview round, and Interview Prep pulls coding, design and behavioural rounds into one plan. If a pattern still feels shaky, go back to the matching lesson in Algorithms & Patterns.
Real practice matters as much as the next course:
- Run timed mock rounds. With a friend or a peer platform, 45 minutes, out loud, with the interviewer taking notes. Swap roles: scoring someone else teaches you what interviewers see.
- Use the Decoder on new problems. The Decoder at /practice/decode walks you through the same stages this course taught, one at a time.
- Join timed contests or assessments. Weekly online contests train reading fast and testing under a hard clock, which is the online assessment format.
- restatement
- The problem said back in one plain sentence with the story stripped out, used to catch misreadings before you code.
- time budget
- About 10^8 simple operations per second, which turns the constraints into a target complexity.
- deciding clue
- The one fact in a prompt, like sorted input or negative values, that separates two candidate patterns.
- test oracle
- A trusted, usually brute-force, solution you compare a faster one against on many random inputs.
- invariant
- A rule your loop keeps true at every step, stated before coding and checked in a dry run.
- monotonic check
- A yes or no test that flips only once as the input grows, which makes binary search on the answer possible.
- mistake log
- A record of each problem you missed and the one insight you lacked, redone on a schedule.