This commit is contained in:
1AoB 2024-04-24 16:31:39 +08:00
parent 6f0f70d3fd
commit 67d61bcc14

View File

@ -0,0 +1,62 @@
+++
author = "Wxn"
title = "给个offer"
date = "2024-04-24"
description = "Please read me first."
tags = [
"Dilay",
]
categories = [
"面试复盘",
]
+++
This article offers a sample of basic Markdown.
<!--more-->
# 正文开始
# 1.41. 包含min函数的栈
```cpp
//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();
*/
```