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
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 161 |
2 | maomao90 | 160 |
3 | awoo | 159 |
4 | atcoder_official | 157 |
5 | -is-this-fft- | 155 |
5 | nor | 155 |
5 | adamant | 155 |
8 | Um_nik | 152 |
8 | maroonrk | 152 |
10 | djm03178 | 146 |
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
Название |
---|
Use greedy and don't use dp because why not
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)
Thanks
Glad to help. Ask me if you don't understand my solution.