# Finding MEX of a changing set

I am trying to create a method add that adds elements x to the set one by one and returns MEX (=minimum non-negative number not in the set) of the list at each point. class Mex: def __init__(self): self.mex = set() def add(self, x): self.mex.add(x) mex = 0 while mex in self.mex: mex += 1… Read More Finding MEX of a changing set