Practise greedy coding questions involving ordering, intervals, scheduling and choices that need a clear correctness argument.
Log in/Sign up to track your progress
Striver’s Greedy Algorithms Sheet contains 16 coding questions. It retains all 14 practice questions from the corresponding A2Z section and two additional questions from existing TUF resources. The practice covers decisions made through ordering, intervals, scheduling and resource constraints.
Striver’s Greedy Algorithm Sheet contains 16 problems on allocation, jumps, intervals, scheduling and decisions constrained by neighbouring or future requirements. Some use sorting to expose the next useful choice. Others maintain a reachable boundary, available resources or a range of possible states. The shared skill is identifying information that lets you avoid exploring every possibility.
Try to describe the objective before naming a sorting rule or data structure. Choosing more compatible activities, merging covered intervals and counting simultaneous resource needs are different tasks, even though all involve intervals. A correct approach starts with the result being requested, then works backwards to the local decision that supports it.
Some questions choose the next available item after sorting; others compare interval boundaries or maintain enough information to make a local decision. A decision that looks useful on one example is not automatically safe. The task’s conditions determine whether an exchange argument, a maintained bound or another correctness explanation supports the greedy choice.
Know arrays, sorting, comparisons and interval notation. Some questions also require a suitable collection or priority queue, so learn those operations where the question uses them. Review the array and sorting foundations before attempting these problems.
Be comfortable sorting records by one field, comparing ties and scanning an ordered sequence. For interval tasks, know what the start and end mean and whether touching endpoints count as overlapping. For scheduling, read whether work can be split, when it becomes available and what time or resource each choice consumes.
Learn to challenge an attractive rule with a small counterexample. Fractional knapsack permits taking part of an item, which supports a value-to-weight choice. A zero-or-one version does not share that permission. Similarly, choosing the earliest start is not the same as choosing the earliest finish when the objective is to attend as many compatible meetings as possible.