#What is a data structure in python to

1 messages · Page 1 of 1 (latest)

timid helm
#

Example que: There is a stream of push(x) and pop(x) operations into an array, and you have to return min(arr)*max(arr) after every turn.

#

Our Python solution was to do one min-heap and one max-heap using heapq, but it always ran into TLE, since removing the element wasn't as simple as said.

#

Then we tried using Java TreeMap as counter, and used TreeMap.firstKey() and TreeMap.lastKey(). This Map internally implements a Red-Black tree to handle the operations. And it worked in first go only