MAXMEX - Editorial

Last one should be -1 since 2 is absent.

1 Like

Shittiest problem statement ever, should’ve better explained maybe

3 Likes

Atleast 2 sample test cases must have been there. Even the confusing problem statement can be ignored if we look at multiple sample test cases. With only 1 sample TCs, many got WA!

1 Like

in that case mex will be 1

  1. It is not necessary that input starts from 1, if m>1 and 1 is not present then the answer will be -1 always as 1 is the smallest positive integer.(every positive integer up to m-1 should be present otherwise answer will be -1)
  2. Order of the input don’t matter i guess, since only the presence of element matters.

for this array A mex will be 7 and largest posible sequence with mex=6 is {1,2,3,4,5}

No where it was told that duplicate element can be present, later on it was mentioned in comments.
Also please take good examples in explanations.
Codechef needs learn alot from codeforces.

1 Like

can anyone tell me code to find mex here in c language

can you please check why i am getting wrong ans?

code

Why are you doing binary search? See this CodeChef: Practical coding for everyone

YES but your code prints 3.

Man you should have specified chosen elements should start from ā€”ā€œ1ā€ā€”
, statement felt incomplete…just a suggestion for you guys for next time.

Can we have integers in jumbled order since the question does not talk about ordering of the sequence?

Can someone please help me out with my solution?
https://www.codechef.com/viewsolution/34589200

Tester’s solution is wrong it should be (i<m) instead of (i!=m).

I think the test cases for this problem are weak. What will be the answer if you are given the following test case?
1
10 4
1 2 3 5 6 8 9 10 11 12
CodeChef: Practical coding for everyone has passed all the test cases but fails for the above test case.
My code gives 5 as the answer which I think is correct but his code gives 10. Please check the test cases for this problem @rezwanarefin01 @raja1999.

hey if the input is 4 5 6 8 9 and M=7 then what should be output

What if the input is 4 7 8 and M=5 what should be the output

Isn’t the correct answer 10? You can choose all the numbers in the sequence and the smallest number which does not exist in this sequence is 4. Hence the answer is 10?

I found the statement confusing, quite honestly. Please try to give at least 2 test cases with proper explanation, I ended up confused about what MEX actually is, ā€œchosenā€ is the word that killed my rating.

1 Like