Easy and Medium
EasyMixed warm-up set
Problem
A warm-up mixed set. Approach every problem the same way: understand the statement, find the pattern (hashing, two pointers, math…), reason about time/space, then implement and test on the examples.
Warm-up problems: spot the pattern, then code it.
The idea
A mixed bag with no single technique. Work each one the same way: identify what is being asked, look for a familiar shape — a frequency count, two pointers, a running total, a sort — and only then reach for the code.
The trick
- Most easy problems are one of four things: counting, sorting, scanning with a running value, or a hash lookup.
- If a nested loop repeats a computation, precomputing it usually collapses the complexity.
This one walks through the worked example rather than tracing the algorithm frame by frame — a full walkthrough is still to be drawn. The code and the idea below are the real solution.
Step 1 of 2. Here's the example — nums = [2, 7, 11], target = 9 Values: 2, 7, 11.
1// general problem-solving loop2understand -> brute force -> spot the pattern3-> optimise -> test on examplesInput
- array
- [2, 7, 11]
Output
- answer
- —
Check yourself
1 quick question about this walkthrough. A wrong answer costs nothing.
Example
- Input:
- nums = [2, 7, 11], target = 9
- Output:
- [0, 1]
- Explanation:
- The easy version tries every pair. The medium version remembers what it has seen, and that single change is the whole step up in difficulty.
Finished the walkthrough? Add it to your streak.