skit using dynamic programming method