mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-28 19:43:31 +08:00
c++
This commit is contained in:
parent
6f0f70d3fd
commit
67d61bcc14
62
exampleSite/content/post/给个offer/index.zh-cn.md
Normal file
62
exampleSite/content/post/给个offer/index.zh-cn.md
Normal 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();
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue
Block a user