How do I know if the problem is of greedy or dynamic programming?

How can I know after seeing the problem statement that if the problem will be solved using greedy approach or dynamic programming approach?

@raghav6 Both DP and Greedy are used in optimization problems. With optimization problems, you see terms like shortest/longest, minimized/maximized, least/most, fewest/greatest, biggest/smallest, etc.
Some problems might look greedy but actually it is DP. So we need to verify all types of test cases if applying Greedy. In contests you can get a hint that a problem is greedy if the constraints are large( 10^5 or large). If constraints are small, say 0<N<10^3 or 0<N<10^4 or 0<N<10^5(only in case of Linear DP) and the problem is of optimization type then most probably it requires DP.

Hope this helps :slightly_smiling_face:

Thank you!! @pratyush63 :smiley:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.