Update appNew update is available. Click here to update.
About
I am a hardworking college student who is aspiring to become a full stack developer .
Babu banarsi das institute of technology 2025
My Stats
EXP gained
yellow-spark
8183
Level
6 (Specialist)
Community stats
Discussions
0
Upvotes
0
Know more
145
Total problems solved
103
Easy
37
Moderate
5
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

7 days

Less

More

Achievements
1
Ronin
Topics
Arrays
2
Samurai
Topics
Linked List
+ 1 more
1
Sensei
Guided path
Pointers
Discussions
I dont know what is wrong with it
Interview problems

// Stack class.

#include<bits/stdc++.h>

class Stack {

    

public:

    int i;

    int *st;

    int size;

    Stack(int capacity) {

        this->size = capacity;

        st = new int[size];

        i = -1;

    }


 

    void push(int num) {

        if(i < size) st[++i] = num;

        return;

    }


 

    int pop() {

        if(i>-1){

            int e = st[i--];

            return e;

        }

        return -1;

    }

    

    int top() {

        if(i>-1) return st[i];

        return -1;

    }

    

    int isEmpty() {

        return (i==-1)?1:0;

    }

    

    int isFull() {

        return (i==size-1)?1:0;

    }

    

};

 

It is giving this error

 

Compilation Error :

Compilation Failed In file included from runner.cpp:9:0: solution.h:7:20: error: expected identifier before numeric constant     vector st(10001,-1);                    ^ solution.h:7:20: error: expected ',' or '...' before numeric constant solution.h: In constructor 'Stack::Stack(int)': solution.h:10:9: error: '((Stack*)this)->Stack::st' does not have class type         this->st.resize(capacity,-1);         ^ solution.h: In member function 'void Stack::push(int)': solution.h:16:44: error: invalid types '[int]' for array subscript         if(this->isize) this->st[++i] = num;                                            ^ solution.h: In member function 'int Stack::pop()': solution.h:22:33: error: invalid types '[int]' for array subscript

 

 

profile
7th_one
Published On 05-Oct-2023
300 views
2 replies
0 upvotes
HELP!
Interview problems

How one can solve this using bit manipulation

profile
7th_one
Published On 20-Aug-2023
35 views
2 replies
0 upvotes