MAXMEX - Editorial

I donโ€™t think the set you mentioned latter has mex = 8. It is given in the question that we are to find the smallest positive number. It is not mentioned that it should belong to the given set.

1 Like

https://www.codechef.com/viewsolution/34615406

can someone help me what was wrong with my code??
pls review this codeโ€ฆ

yeah, nor they mentioned that multiple occurences are possible, I am not supposed to keep looking up in the comment section for clarification.

5 Likes

smallest positive integer which does not occur among the chosen elements

We are choosing a particular subset from the given set and checking MEX for that subset

3 Likes

Sorry, it was a typing mistake.

Even I made the same mistake :frowning:

They give two statements themselves
Editorial : MEX of a sequence is the smallest positive integer not present in the sequence.
Problem: MEX, i.e. the smallest positive integer which does not occur among the chosen elements.
These two statement are not similiar
@taran_1407

5 Likes

The answer in this case is -1.

MEX of a sequence is the smallest positive integer not present in the sequence.
So in subsequence {4,5,6,7,9,10} it will be 1 as 1 is the smallest positive number not present in the subsequence.

Please explain your approach. Did you consider multiple occurence of integers?

I think the problem statement could have been made a little more clear with 1 or 2 more input-output examples.

6 Likes

How though?

I made the same incorrect assumption and ended up solving only one question :โ€™(

1 Like

Unless specified that array elements are unique, you ought to assume that only.

1 Like

You are right bro

MEX, i.e. the smallest positive integer which does not occur among the chosen elements

M=3
Given set = {1, 2, 4}
Acc to answer chosen set is {1, 2, 3}. So the elements which donot occur among the chosen elements are : NULL
Smallest among NULL is 3? Please explain

1 Like

When you are using the word among the elements , it signify that you are using some lower and upper bound

3 Likes

made the same assumption :pensive:

Because

Editorial : MEX of a sequence is the smallest positive integer not present in the sequence.
Problem: MEX, i.e. the smallest positive integer which does not occur among the chosen elements.

chosen elements is a subset of sequence

Yeah, but which elements you chose depends on you.