O89
Monotonic Maximum Queue
Problem Statement & Objective
Implement a queue that supports push, pop, and max_value queries in amortized O(1) time.
Function Signature (Python)
monotonic_maximum_queue(operations: list) -> listInput & Output Contract
Output Rule:İşlem sonuçları listesi (None veya int).
System Constraints
1 <= islemler.length <= 10^4
-10^5 <= val <= 10^5Example Execution Walkthrough
islemler = [['push', 1], ['push', 2], ['max_value'], ['pop'], ['max_value']]
push 1
push 2
max_value -> 2
pop -> 1
max_value -> 2
Cevap: [None, None, 2, 1, 2]Example Test Scenarios (3)
Example 1: Basic Maximum
Input:
[[["push",1],["push",2],["max_value"],["pop"],["max_value"]]]Expected Output:
[null,null,2,1,2]Example 2: Boş Kuyruk
Input:
[[["pop"],["max_value"]]]Expected Output:
[-1,-1]Example 3: Single Element
Input:
[[["push",5],["max_value"],["pop"]]]Expected Output:
[null,5,5]