Not working for some test cases


vector v;
//int minx=INT_MAX;
//set s;
MinStack::MinStack() {

void MinStack::push(int x) {
//if(x < minx)minx=x;

void MinStack::pop() {
if(v.size()==0)return ;

int MinStack::top() {
if(v.size()==0)return -1;
return v[v.size()-1];

int MinStack::getMin() {
if(v.size()==0)return -1;
return *min_element(v.begin(),v.end());


That is because you are not clearing your global variable. Write v.clear() in constructor and it will work.
But anyway this would not earn you full points because it needs to be done in constant time and *min_element takes O(n) time.