-
1019. Next Greater Node In Linked List
Oct 10, 2020
今天的题目是1019. Next Greater Node In Linked List。 这种求下一个更大的元素用单调栈就可以解决了。 简单来讲,就是从后往前遍历,每次都将当前元素压入栈中,…
-
Binary Search Tree Iterator
Mar 31, 2020
貌似又是一道之前做了,但是没写题解的题目。 今天的题目是Binary Search Tree Iterator。 这道题要求我们按从小到大的顺序返回二叉搜索树的值,而…
-
Evaluate Reverse Polish Notation
Mar 31, 2020
因为最近在总结 LeetCode 中 Stack 标签下做过的题目,然后这道题做了但是没有写题解,所以补充一下。 一道Medium的题目,但是数据结构课上提到栈时,都会举这…
-
Binary Tree (Preorder|Inorder|Postorder) Traversal
Mar 24, 2020
今天将二叉树的先、中、后遍历的做了一些总结。三种遍历都有三种写法: 递归 时间复杂度:O(n) 空间复杂度:O(h),h为树高 基于栈进行迭代: 时间…
-
LeetCode Stack Tag 总结
Mar 23, 2020
准备按 Tag 过一遍之前刷过的 LeetCode,总结一些常用的技巧和套路。 题目列表 Name No Difficulty Blog Link Note Valid Parentheses 20 Easy https://blog.codeand.fun/2017/09/24/Valid-Parentheses/ 可以建一个右括号到左括号的map来使代码更…
-
Decode String
Nov 08, 2019
第四天。 今天的题目是Decode String: Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No…
-
Simplify Path
Mar 02, 2019
第三天(hhh,好像又很久没刷了), 又AC掉了逻辑题,或者说又是一道用if else加状态机搞定的题。 今天的题目是71. Simplify Path 以后还是不copy…
-
Verify-Preorder-Serialization-of-a-Binary-Tree
Feb 19, 2018
第104天。 今天的题目是331. Verify Preorder Serialization of a Binary Tree: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node’s value. If it is a null node, we record using a sentinel value such as #. _9_ / \ 3 2 / \ / \…
-
Flatten-Nested-List-Iterator
Feb 14, 2018
第100天。 今天的题目是flatten-Nested-List-Iterator: Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list – whose elements may also be integers or…
-
Binary-Tree-Zigzag-Level-Order-Traversal
Feb 11, 2018
第97天。 今天的题目是Binary Tree Zigzag Level Order Traversal: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag…