Update the smallest elements row - wise
for i in range ( N ) : NEW_LINE INDENT for j in range ( M - K + 1 ) : NEW_LINE INDENT mn = sys . maxsize NEW_LINE for k in range ( j , j + K ) : NEW_LINE INDENT mn = min ( mn , nums [ i ] [ k ] ) NEW_LINE DEDENT nums [ i ] [ j ] = mn NEW_LINE DEDENT DEDENT