1. Implement a Stack using Linked List . 2. Implement the operations push() and pop().
Input Format
First line of each test case contains an integer Q denoting the number of operations. Second line contains Q operations For push(x) write 1 x, for pop() write 2.
Output Format
Space separated integers having -1 if the stack is empty else the element poped out from the stack .
Constraints
1 <= Q <= 100 1 <= x <= 100
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
4 2 1 4 1 5 2
Output
-1 5