![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
堆栈
1000sakura
https://home.cnblogs.com/u/1000sakura/
展开
-
【LeetCode】Valid Parentheses(有效的括号)
这道题是LeetCode里的第20道题。题目要求:给定一个只包括'(',')','{','}','[',']'的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。示例 1:输入: "()"输出: true示例2:输入: "()[]{}"输出: true...原创 2019-03-16 10:21:27 · 181 阅读 · 0 评论 -
【LeetCode】Binary Tree Preorder Traversal(二叉树的前序遍历)
这道题是LeetCode里的第144道题。题目要求:给定一个二叉树,返回它的前序遍历。示例:输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,2,3]进阶:递归算法很简单,你可以通过迭代算法完成吗?解题代码:/** * Definition for a binary tree node....原创 2019-03-30 14:59:52 · 147 阅读 · 0 评论 -
【LeetCode】Binary Tree Inorder Traversal(二叉树的中序遍历)
这道题是LeetCode里的第94道题。题目要求:给定一个二叉树,返回它的中序遍历。示例:输入: [1,null,2,3] 1 \ 2 / 3输出: [1,3,2]进阶:递归算法很简单,你可以通过迭代算法完成吗?解题代码:/** * Definition for a binary tree node. * str...原创 2019-03-30 15:05:19 · 116 阅读 · 0 评论 -
【LeetCode】Binary Tree Postorder Traversal(二叉树的后序遍历)
这道题是LeetCode里的第145道题。题目要求:给定一个二叉树,返回它的后序遍历。示例:输入: [1,null,2,3] 1 \ 2 / 3 输出: [3,2,1]进阶:递归算法很简单,你可以通过迭代算法完成吗?解题代码:/** * Definition for a binary tree node. ...原创 2019-03-30 15:10:19 · 150 阅读 · 0 评论 -
【LeetCode】Min Stack(最小栈)
这道题是LeetCode里的第155道题。题目描述:设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。push(x)-- 将元素 x 推入栈中。 pop()-- 删除栈顶的元素。 top()-- 获取栈顶元素。 getMin() -- 检索栈中的最小元素。示例:MinStack minStack = new MinStack();...原创 2019-04-30 21:51:35 · 341 阅读 · 0 评论 -
【Codewars】Valid Braces
Codewars里的 6kyu Kata。题目说明:Write a function that takes a string of braces, and determines if the order of the braces is valid. It should returntrueif the string is valid, andfalseif it's inval...原创 2019-05-18 16:12:30 · 427 阅读 · 0 评论