How can I retrieve the max and min element from a queue at any time in 0(1) time complexity?
Earlier I was using Collections.max and min to find the elements but that would be 0(n).
How can I retrieve the max and min element from a queue at any
Share
You only have 2 ways to get O(1) for a min/max operation: