Someone please help me understand the problem statement , its not clear , the contest has ended someone with an approach please guide!!
I didn’t solve the problem but I can explain the statement.
So , it basically says that you have to find out the number of ways you can partition the array into contiguous subarrays such that their MEX is same.
You can search the meaning of MEX online but it simply is the smallest non-negative int not present in a sequence. e.g MEX of (1,2,3) = 0.
One approach is that you can observe that you have to divide the array in such a way that the MEX of all subarrays should be equal to the MEX of whole array. This is because at some point you are going to include the elements that make the MEX say x. Didn’t code this just giving you the idea.
well I think that as per definition of MEX considering an array 1 2 3 4 5 the smallest non neg int is 6 not present in array so its not present else where right ?
So how to calculate the number of ways further?
Ya even i had the same idea , but can you please implement it and put the code here.
I wrote a brute force recursive solution but cant figure out how to memoize .
No for 1 2 3 4 5 mex will be 0. Non-negative includes 0.
Ok I will help u out by tomorrow ! gonna sleep ! Good night !! Thanks for this!!
The MEX for 1 to 5 will be 0.
You can check out the editorial here. Pretty good explanation. MEXSUB - Editorial
0 is +ve / -ve integer?
Non-negative means numbers that are not negative i.e. 0 and positive.
Neither positive nor negative , it is non positive and non negative no.