C++ Easy Solution ✅ || Using 2 Stacks
Code\n\n\tclass MinStack {\n\tpublic:\n\t\tstack<int>s,minn;\n\t\tvoid push(int val) {\n\t\t\ts.push(val); // push val in stack\n\n\t\t\tif(minn.size()==0 || va
# Code\n```\n\tclass MinStack {\n\tpublic:\n\t\tstack<int>s,minn;\n\t\tvoid push(int val) {\n\t\t\ts.push(val); // push val in stack\n\n\t\t\tif(minn.size()==0 || val<=minn.top()){//push in when empty or lesser than current minElement\n\t\t\t\tminn.push(val);\n\t\t\t}\n\t\t}\n\n\t\tvoid pop() {\n\n\t\t\tif(minn.top() == s.top())//pop when last element was min element \n\t\t\t\tminn.pop();\n\t\t\ts.pop();\n\t\t}\n\n\t\tint top() {//return top of stack\n\t\t\treturn s.top();\n\t\t}\n\n\t\tint getMin() {//return top of minKeeper\n\t\t\treturn minn.top();\n\t\t}\n\t};\n```\n![9c6f9412-c860-47d6-9a2e-7fcf37ff3321_1686334926.180891.png](https://assets.leetcode.com/users/images/26e6c414-ed21-4e56-bc72-60bdb723a8a2_1705328113.4163136.png)\n
['Stack', 'C++']