added one more task: DP solution