Add max skip depth in dynamic programming algorithm.