link on JianShu
栈stack
496. Next Greater Element I Easy
You are given two arrays (without duplicates) nums1
and nums2
where nums1’s
elements are subset of nums2
. Find all the next greater numbers for nums1's
elements in the corresponding places of nums2
.
link on JianShu
栈stack
42. Trapping Rain Water Hard
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
link on JianShu
栈stack
71. simplify path Medium
Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.
link on JianShu
栈stack
225. Implement Stack using Queues Easy
232. Implement Queue using Stacks Easy
这两道提互为实现,刚好放到一起学习。既然两种数据结构可以互相实现,可以看看有什么相似之处。
link on JianShu
栈stack
173. Binary Search Tree Iterator Medium
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next()
will return the next smallest number in the BST.