Greedy practice problems
Take the best step now and prove you never have to take it back. A pattern: a move you make, and the kind of thing an interview is really asking you to spot. 11 problems in the bank train it, each with a worked example, a hint and a reference solution.
- Math
- Strings
- Arrays
- Hash maps
- Sorting
- Parsing
- Two pointers
- Sliding window
- Prefix sums
- Stacks
- Binary search
- Intervals
- Grids
- Greedy
- Recursion
- Simulation
- Bit manipulation
11 problems
- Find the first free slot in a dayhard
- Wrap text to a label widthhard
- Split a total into installmentshard
- Distribute candies by ratinghard
- How many rooms are needed at peakhard
- The smallest van that still finishes on timehard
- Pick an order off the shelvesmedium
- Pick the coupon worth mostmedium
- How long to clear the order bookmedium
- Write a number in Roman numeralsmedium
- Apply credits to an invoicemedium