Please read the new rule regarding the restriction on the use of AI tools. ×

HELP needed mex problem

Revision en1, by TCS_Bhediya, 2024-10-04 09:33:03

Problem Link
In this problem, I'm keeping track of some element greater than the current element is present in the suffix. I'm iterating the array, putting its element on the map, and tracking the maximum element. If the map size becomes (mx + 1), all the numbers from 0 to mx are present. Now, I can either append the mex of this array or move forward. I will move forward if some element greater than the mx element of the current mex array is present in the suffix. It's giving WA in test case 4, as it's appending an extra 4 mex (2 1 1 1), making its size 98 instead of 94. I'm wondering where the problem might be in my approach or implementation. 284266809

Tags mex, maths, greedy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English TCS_Bhediya 2024-10-04 09:33:03 756 Initial revision (published)