Find the MEX of all subarrays of length K by erasing arr [ i ] and inserting arr [ i - K ]
for i in range ( K , N , 1 ) : NEW_LINE INDENT s . remove ( arr [ i ] ) NEW_LINE s . add ( arr [ i - K ] ) NEW_LINE DEDENT