A 24]7.ai conversation workflow needs a last-in, first-out history of event identifiers so the most recent event can be inspected or removed first. Implement the stack behavior for a sequence of operations.
Create a function that processes operations in order:
push(value) adds value to the top of the stack and produces no output.pop() removes and returns the top value.top() returns the top value without removing it.The input is represented as a list of operation arrays. A push operation has the form ["push", value]; pop and top operations have the form ["pop"] and ["top"]. Return a list containing results from pop and top operations in their original order. Do not include output for push operations.
Given operations, a list of operation arrays containing integer values, return a list of integers produced by pop and top. The input guarantees that pop and top are never called when the stack is empty.
def process_stack(operations):