Does python have a sorted list?

前端 未结 7 1883
温柔的废话
温柔的废话 2020-11-29 20:16

By which I mean a structure with:

  • O(log n) complexity for x.push() operations
  • O(log n) complexity to find an element
  • O(n) comple
7条回答
  •  醉梦人生
    2020-11-29 20:52

    I would use the biscect or sortedcontainers modules. I don't really am experienced, but I think the heapq module works. It contains a Heap Queue

提交回复
热议问题