Store the final submatrix with required minimum values
for i in range ( N - K + 1 ) : NEW_LINE INDENT for j in range ( M - K + 1 ) : NEW_LINE INDENT res [ i ] [ j ] = nums [ i ] [ j ] NEW_LINE DEDENT DEDENT