Блог пользователя C_o_d_e__

Автор C_o_d_e__, история, 9 дней назад, По-английски

you have an array in one operation choose two different element and remove from array return minimum length of array
you can do this operation any number of times

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Use greedy and don't use dp because why not

»
9 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Store the count of all elements using a map.

If there is an element whose count x>floor(n/2) then answer is x-(n-x);

Else answer is 0 if n is even and 1 if n is odd.

(n=size of the array)