11/*
22 written by Pankaj Kumar.
33 country:-INDIA
4- Institute: National Institute of Technology, Uttarakhand
54*/
65typedef long long ll ;
7- typedef unsigned long long ull;
8- typedef vector<int > vl;
9- typedef vector<vector<int >> vvl;
10- #define speed cin.tie(0 );cout.tie(0 );ios_base::sync_with_stdio(0 );
11- /* Abbrevations */
12- #define ff first
13- #define ss second
14- #define mp make_pair
15- #define pb push_back
16- // loops
17- #define forin (arr,n ) for (ll i=0 ;i<n;i++) cin>>arr[i];
18- // Some print
19- #define no cout<<" NO" <<endl;
20- #define yes cout<<" YES" <<endl;
21- // sort
22- #define all (V ) (V).begin(),(V).end()
23- #define srt (V ) sort(all(V))
24- #define srtGreat (V ) sort(all(V),greater<ll>())
25- // some extra
26- #define printv (v ) for (ll i=0 ;i<ll(v.size());i++){cout<<v[i]<<" " ;} cout<<endl;
27- #define precision (x ) cout<<fixed<<setprecision(x);
28- #define sz (V ) ll(V.size())
29-
30-
31- /* ascii value
32- A=65,Z=90,a=97,z=122
33- */
34-
35- /* Some syntax
36- //Syntax to create a min heap for priority queue
37- //priority_queue <int, vector<int>, greater<int>>pq;
38- */
39- /* --------------------MAIN PROGRAM----------------------------*/
40- // to run ctrl+b
416const ll INF=1e18 ;
427const ll mod1=1e9 +7 ;
438const ll mod2=998244353 ;
44- // Techniques :
45- // divide into cases, brute force, pattern finding
46- // sort, greedy, binary search, two pointer
47- // transform into graph
48-
49- // Experience :
50- // Cp is nothing but only observation and mathematics.
51-
52-
539// Add main code here
5410
55- class MyStack {
11+ class MyStack
12+ {
5613public:
5714 /* * Initialize your data structure here. */
5815 queue<int > q;
5916
60- MyStack () {
17+ MyStack ()
18+ {
19+ q.clear ();
6120 }
62-
21+
6322 /* * Push element x onto stack. */
64- void push (int x) {
23+ void push (int x)
24+ {
6525 q.push (x);
6626 }
67-
27+
6828 /* * Removes the element on top of the stack and returns that element. */
69- int pop () {
29+ int pop ()
30+ {
7031 queue<int > temp;
71- while (q.size ()>1 ){
32+ while (q.size () > 1 )
33+ {
7234 temp.push (q.front ());
7335 q.pop ();
7436 }
75- int t= q.front ();
37+ int t = q.front ();
7638 q.pop ();
77- q= temp;
39+ q = temp;
7840 return t;
7941 }
80-
42+
8143 /* * Get the top element. */
82- int top () {
44+ int top ()
45+ {
8346 return q.back ();
8447 }
85-
48+
8649 /* * Returns whether the stack is empty. */
87- bool empty () {
88- return q.size ()==0 ;
50+ bool empty ()
51+ {
52+ return q.size () == 0 ;
8953 }
9054};
9155
@@ -97,14 +61,3 @@ class MyStack {
9761 * int param_3 = obj->top();
9862 * bool param_4 = obj->empty();
9963 */
100-
101-
102-
103- /* -----------------END OF PROGRAM --------------------*/
104- /*
105- * stuff you should look before submission
106- * constraint and time limit
107- * int overflow
108- * special test case (n=0||n=1||n=2)
109- * don't get stuck on one approach if you get wrong answer
110- */
0 commit comments