Implement Stack using Linked List
Difficulty: Easy
Acceptance: %
Points: 20.00
You are provided with a linked list and need to implement the push and pop functionalities of a stack using this linked list. Your task is to complete the push() and pop() methods in the given class template. The push() method accepts an integer x as input and adds it to the stack, while the pop() method removes and returns the integer at the top of the stack. If the stack is empty, the pop() method should return -1.
Note: The input consists of a series of queries representing operations on the stack. There are two types of queries, as described below:
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)