Wrote greedy solution but think for DP