What clues do you usually look for when identifying a Greedy problem during a contest? Are there any common patterns, constraints, or characteristics that help you recognize one? I'd love to hear your approaches and experiences!
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 133 |
| 10 | cry | 130 |
What clues do you usually look for when identifying a Greedy problem during a contest? Are there any common patterns, constraints, or characteristics that help you recognize one? I'd love to hear your approaches and experiences!
| Name |
|---|



Look for problems where the best local choice leads to the global optimum. Always verify that the greedy choice is valid.
But what techniques do you personally use to verify that a local optimal choice will actually lead to a global optimum? Do you rely on mathematical proofs, testing, or both?"
I usually combine two approaches: First, I try to prove that swapping any optimal solution with my greedy choice won’t worsen it. Second, in contests, I code a brute-force DP/backtracking for small n and compare outputs against my greedy solution on random tests. Last, If I can’t find a counterexample, I will submit the code. Actually, it’s enough to practice more greedy algorithm problems to get the hang of it; that’s what I did.
I am a middle school student from China; my English is not very good, please understand.
That's a solid approach! Comparing greedy with brute force is a great way to catch mistakes. And I agree, consistent practice makes a huge difference. Thanks for sharing!
Your English is probably better than mine and im a hs student from America
I try to prove that choosing differently cannot produce a better result, rather than relying only on testing.
Maybe it's intuition. In fact, a lot of beginner problems are greedy. The more you practice, the more intuition you get when facing harder problems, and you can often tell they're greedy just by checking, without needing to use DP.
If the problem requires a linear time solution (you can know that from the constraints) I think of the most stupid way to solve the problem and then try to improve it using some observations, if those observation lead to a greedy solution I try to disprove it with some counter example rather than proving it.
Interesting approach! I like the idea of actively trying to disprove a greedy solution with counterexamples rather than blindly trusting it.