Last one should be -1 since 2 is absent.
Shittiest problem statement ever, shouldāve better explained maybe
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!
in that case mex will be 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)
- 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.
can anyone tell me code to find mex here in c language
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?
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.