For more details, please go through - Optimal Substructure Property in Dynamic Programming, Overlapping Subproblems Property in Dynamic Programming