题解 | 自动管理停车场桩位系统

自动管理停车场桩位系统

https://www.nowcoder.com/practice/4c7f2556e7e8436189202942b4fa07e4

#include <cmath>
#include <stack>
#include <vector>
class Solution {
public:
stack<int> zhan;
    void push(int value) {
        zhan.push(value);
    }
    void pop() {
        zhan.pop();
    }
    int top() {
        return zhan.top();
    }
    int min() {
        int min = pow(10, 9) + 1;
        vector<int> shuzu;
        while (!zhan.empty()) {
            shuzu.push_back(zhan.top());
            if (min > zhan.top()){
                min = zhan.top();
            }
            zhan.pop();
        }
        for (int i = shuzu.size() - 1; i >= 0; i--){
            zhan.push(shuzu[i]);
        }

        return min;
    }
};

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务