DP ਅਤੇ greedy ਦੋਵਾਂ ਨੂੰ optimal substructure ਦੀ ਲੋੜ ਹੁੰਦੀ ਹੈ। ਫਰਕ: greedy ਨੂੰ greedy-choice property ਵੀ ਚਾਹੀਦੀ ਹੈ (ਇੱਕ local optimum globally optimal ਹੈ), ਜਦਕਿ DP ਦੀ ਲੋੜ ਉਦੋਂ ਹੈ ਜਦੋਂ ਤੁਹਾਨੂੰ ਮਲਟੀਪਲ choices ਅਤੇ overlapping subproblems 'ਤੇ ਵਿਚਾਰ ਕਰਨਾ ਪਏ।
