mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
97 lines
1.6 KiB
Markdown
97 lines
1.6 KiB
Markdown
+++
|
||
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();
|
||
*/
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
# 2.35. 反转链表
|
||
|
||
```cpp
|
||
/**
|
||
* Definition for singly-linked list.
|
||
* struct ListNode {
|
||
* int val;
|
||
* ListNode *next;
|
||
* ListNode(int x) : val(x), next(NULL) {}
|
||
* };
|
||
*/
|
||
//https://leetcode.cn/problems/reverse-linked-list/
|
||
//难点:单链表要建立一个前驱节点
|
||
//关键点:画图
|
||
class Solution {
|
||
public:
|
||
ListNode* reverseList(ListNode* head) {
|
||
|
||
}
|
||
};
|
||
```
|
||
|
||

|
||
|
||
# 3.19. 二叉树的下一个节点
|
||
|
||
```cpp
|
||
|
||
```
|
||
|