How do I identify Greedy vs Dynamic Programming problem

One of the biggest challenges I find in solving coding question is to identify whether to solve it using greedy or dynamic programming. A lot of time I would spend significant time trying to find a dynamic programming solution, only to fail and then look at the solution to see a greedy approach. Is there any way (or dare I say, 'trick') to identify what is the best approach.

Comments (1)