题目描述 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。 解题思路 用一个栈stack保存数据,用另外一个栈temp保存依次入栈最小的数 比如,stack中依次入栈 5, 3, 4, 10, 2,…
分类:LeetCode
【LeetCode】- Fist Missing Positive
1、题目描述 Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] …
130. Surrounded Regions
130. Surrounded Regions 题目 Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surroun…
[LeetCode] Largest Plus Sign 最大的加型符号
In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in t…
[Leetcode] Candy 分糖果
Candy There are N children standing in a line. Each child is assigned a rating value. You are giving candies t…
LeetCode | Edit Distance(字符串编辑距离)
Given two words word1 and word2, find the minimum number of steps required to convert word…
LeetCode算法题-Repeated String Match(Java实现)
这是悦乐书的第289次更新,第307篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第156题(顺位题号是686)。给定两个字符串A和B,找到A必须重复的最小次数,使得B是它的子字符串。 如果…
53. 最大子序和
DP解法 时间复杂度是O(n) 极简版代码 注意事项 ret_max 的初始值应该是nums[0],留给朋友们思考为什么. class Solution(object): def maxSubArray(self, nu…
[LeetCode] Basic Calculator II 基本计算器之二,Basic Calculator 基本计算器
Implement a basic calculator to evaluate a simple expression string. The expression string contains onl…
[LeetCode] Design TinyURL 设计精简URL地址
Note: For the coding companion problem, please see: Encode and Decode TinyURL. How would you desi…
[LeetCode] Maximum Sum of 3 Non-Overlapping Subarrays 三个非重叠子数组的最大和
In a given array nums of positive integers, find three non-overlapping subarrays with maximum…
[LeetCode] 1-bit and 2-bit Characters 一位和两位字符
We have two special characters. The first character can be represented by one bit 0. The second ch…