hugo-theme-stack/exampleSite/content/post/给个offer/index.zh-cn.md
2024-04-24 16:31:39 +08:00

1.1 KiB
Raw Blame History

+++ author = "Wxn" title = "给个offer" date = "2024-04-24" description = "Please read me first." tags = [ "Dilay", ] categories = [ "面试复盘", ]

+++

This article offers a sample of basic Markdown.

正文开始

1.41. 包含min函数的栈

//https://leetcode.cn/problems/bao-han-minhan-shu-de-zhan-lcof/description/
class MinStack {
public:
    /** initialize your data structure here. */
    //1.单调栈
    //2.主栈与辅助栈
    //3.1)push都要插入如果辅助栈为空或者辅助栈顶>=x则辅助栈插入
    //2)pop() 如果辅助栈顶 == 主栈顶,则辅助栈顶弹出,否者就只有主栈弹出
    //3)4)直接返回相应的栈
    MinStack() {
        
    }
    
    void push(int x) {
        
    }
    
    void pop() {
        
    }
    
    int top() {
        
    }
    
    int getMin() {
        
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(x);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.getMin();
 */