Implement a Maximum-Tracking Stack
Company: Zipline
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates competency in data structure design and algorithmic analysis, focusing on stack operations augmented with maximum-tracking and correctness when multiple maximal elements and ordering constraints are present.
Examples
Input: ((('push', 5), ('push', 1), ('push', 5), ('top',), ('popMax',), ('top',), ('peekMax',), ('pop',), ('top',)),)
Expected Output: [5, 5, 1, 5, 1, 5]
Explanation: Standard MaxStack sequence.
Input: ((('push', 3), ('push', 3), ('popMax',), ('pop',)),)
Expected Output: [3, 3]
Explanation: Topmost maximum tie.