大家好,我是老马。
今天我们一起来学习一下栈。
chat
详细介绍一下力扣数据结构之栈
栈(Stack)是 LeetCode 中的高频数据结构之一,常用于括号匹配、表达式求值、单调栈、深度优先搜索等题型。
它具有**先进后出(LIFO)**的特点,操作简单、用途广泛。
🧱 一、栈的基本概念
特性 | 描述 |
---|---|
操作方式 | 先进后出(LIFO) |
主要操作 | push (压栈)、pop (弹栈)、peek (栈顶)、isEmpty |
常见实现 | 数组、链表、双端队列 |
大家好,我是老马。
今天我们一起来学习一下栈。
栈(Stack)是 LeetCode 中的高频数据结构之一,常用于括号匹配、表达式求值、单调栈、深度优先搜索等题型。
它具有**先进后出(LIFO)**的特点,操作简单、用途广泛。
特性 | 描述 |
---|---|
操作方式 | 先进后出(LIFO) |
主要操作 | push (压栈)、pop (弹栈)、peek (栈顶)、isEmpty |
常见实现 | 数组、链表、双端队列 |
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.
Example 1:
Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.
Example 1: