The five questions
transcript
A new problem. Ask five questions. Before any code.
What does it read? What does it return? And when nothing qualifies? Say the answers out loud. Read the limits line by line. Five answers, five lines. Ask the same five each time. Never skip the empty case.
How large is n? How large is a value? The constraints answer both. It takes under a minute. Then pick a class that fits. Keep them beside the editor. Slow down to go faster. Ask what an empty list returns.
What are the edge cases? Smallest n and extreme values. Equal values and the empty answer. It stops wrong starts. Write the edges as tests. Check them against your code. A minute here saves an hour. Write that answer first.
Examples are small on purpose. The limits set the real size. Examples never show the limits. Then start to code. Habits beat hurry. Read, then code. Then loop.
Ask before you code. Full breakdown in the lecture.