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

How to iterate through hashmap efficiently?

Правка en1, от AkeenL, 2021-04-03 23:59:41

For problem BerPizza https://codeforces.me/contest/1468/problem/C the most easy solution is to store the key and values in a hashmap and loop through looking for either largest value or smallest index. This approach gives TLE and when I read the editorial they recommend a treeset but a treeset cannot store duplicate values. Is there a way to iterate through a map faster than o(n) or do I need to use priorityqueues for this problem?

Теги #data structure, #implementation

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский AkeenL 2021-04-03 23:59:41 481 Initial revision (published)