Python: using heapq module to find n largest items
Dec 25, 2020 · 12 min read · Today, I'm going to tell about using the heapq module. As you probably know, the easiest way to find the largest element in a collection in Python is by using the max() method. Or min() to find the smallest one. But what if you need to find n largest...
Join discussion



