Module 4 · if, switch and Loops
CP and Interview Pack: Nested Loops, Early Exit and the Bug Gallery
ProReading
Alice is in a mock interview, and her FizzBuzz just ran clean. The interviewer nods and asks the second question. "Now, given a list of numbers and a target, find the first pair that sums to the target." The loop is easy to start. The hard parts are what this lesson trains: which pairs to visit, how many there are, and how to stop at the answer. Exercise 3 is that exact question, graded.
Checking what this lesson needs for you…
What is inside CP and Interview Pack: Nested Loops, Early Exit and the Bug Gallery
- Counting a nested loop's passes
- The contest angle: O(n2) against a time limit
- Leaving two loops at once
- The off-by-one gallery
- FizzBuzz variations
- Six interview questions, with model answers