@hitesh_noty >> I think you should first understand greedy algorithms and dynamic programming algorithms properly. E.g from video lectures. There are few parameters for which a DP solution can be applied.

There is a term called correctness of an algorithm, which forces you to think backwards and later you can find out real quick about what to choose greedy or DP.

**Typically, a greedy algorithm is used to solve a problem with optimal substructure if it can be proved by induction that this is optimal at each step (Cormen et al. pp. 381â€“2). Otherwise, providing the problem exhibits overlapping subproblems as well, dynamic programming is used.**

Conclusion: Read and practice!