Skip to content
Tech Interview Prep home
Technical interview guide

Greedy Algorithms

Making the locally-best choice at each step and never revisiting it — correct only when the problem has the right structural guarantee.

Read
42 min
Practice MCQs
25
Interview QA
25
Edition
v7
Editorial status
Reviewed

Scope: Language-neutral, with sorting and priority-queue behaviour cited from CPython 3.14.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Explain what makes a greedy algorithm correct and how it changes a production decision.

QA-2

Given an array where each element is the maximum jump length from that position, what is the minimum number of jumps to reach the last index?

QA-3

Walk through the exchange argument, including where engineers most often get it wrong.

QA-4

What does interval scheduling guarantee, and what does it deliberately leave open?

QA-5

Describe interval partitioning and the evidence you would collect before relying on it.

QA-6

When does a greedy solution to knapsack work?

QA-7

Where does coin change and canonical systems matter, and where is it irrelevant?

QA-8

Teach the jump-game reachability rule to an engineer who has only seen it as a rule of thumb.

QA-9

How does Huffman coding use greedy choice to build an optimal prefix-free code?

QA-10

How does Huffman coding construct an optimal prefix code using a greedy approach, and why does the greedy choice yield minimum weighted path length?

QA-11

How do Kruskal's and Prim's algorithms utilize the greedy cut property to build a Minimum Spanning Tree, and how do their data structure choices affect time complexity?

QA-12

How does dijkstra as a greedy algorithm change if the workload grows by two orders of magnitude?

QA-13

How do you solve the interval scheduling problem greedily, and why does sorting by end time succeed where sorting by start time fails?

QA-14

When would you refuse a design because of sorting by a composite key?

QA-15

How would you explain greedy with a heap without using the usual slogan?

QA-16

How do you solve the Gas Station circular tour problem in O(N) time and O(1) space using a greedy approach?

QA-17

How do you prove that a greedy strategy is optimal, and what exchange argument technique is standardly used?

QA-18

What belongs in a runbook section on when greedy is an approximation, and what does not?

QA-19

How would you review a pull request whose risk is greedy versus dynamic programming?

QA-20

What trade-off does finding counterexamples force that a junior answer usually skips?

QA-21

How would you brief product on why stability of the greedy order delays a ship date?

QA-22

What is the smallest experiment that would change your mind about greedy in scheduling systems?

QA-23

How does local optima and hill climbing interact with rollback, and where do people ignore that?

QA-24

What would you ask a candidate who recites the cost of a wrong greedy rule but cannot apply it?

QA-25

How would you document recognising a greedy problem so the next owner can operate it?