sequential dp & matrix dp