You are given an array of integers `arr` and an integer `k` representing the number of operations. Implement a data structure that supports two operations: pushing elements onto the stack and popping elements from the stack, such that the maximum and minimum elements alternate at the top of the stack. After `k` operations, return the top element of the stack.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak