Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

HELP needed mex problem

Правка en1, от 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

Теги mex, maths, greedy

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский TCS_Bhediya 2024-10-04 09:33:03 756 Initial revision (published)