sol using dp
add comments