i am not able to understand the ques,tell me with the sample test case provided.also how to take input in such cases
Prateek sir & coding
hey @Shubham-Singh-1843190805727785, consider the below explanation.
Code modules are kept as a pile. Each module has a cost associated with it. . There are two types of queries:
-
Student Query (indicated by 1): When a student demands a module, the code module on the top of the pile is given and the student is charged according to the cost of the module. This reduces the height of the pile by 1. In case the pile is empty, the student goes away empty-handed. (Pop operation)
-
Instructor Query (indicated by 2): Code module is prepared and added it on top of the pile. And reports the cost of the module. (push Operation)
Whenever student takes a module (input =1), print the price.
Now consider the following sample testcase.
7 //number of query
2 73 //Instructor Query, 73 is cost of module, So push 73, top of the stack= 73
2 83 //Instructor Query, 83 is cost of module, So push 83, top of the stack= 83
2 43 //Instructor Query, 43 is cost of module, So push 43, top of the stack= 43
1 //Student Query, top of the stack= 43, So pop 43 and new top of the stack =83
Output=43
1 //Student Query, top of the stack= 83, So pop 83 and new top of the stack =73
Output=83
2 16 //Instructor Query, 16 is cost of module, So push 16, top of the stack= 16
2 48 //Instructor Query, 48 is cost of module, So push 48, top of the stack= 48
great explaination,question was not clear to me from the problem statement,thanks anyway
hey @Shubham-Singh-1843190805727785 , if your query is resolved. Please mark this doubt as resolved and rate me on the basis of your experience.
rating option will appear when to mark this doubt as resolved