Find the farthest point it can reach from i
j = min ( m , rightMost [ i ] ) NEW_LINE while ( j > i ) : NEW_LINE INDENT dp [ i ] = max ( dp [ i ] , dp [ j ] ) NEW_LINE j -= 1 NEW_LINE DEDENT i -= 1 NEW_LINE