Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8ed34a4 commit 59e320cCopy full SHA for 59e320c
problems/155.min-stack.md
@@ -28,7 +28,7 @@ minStack.getMin(); --> Returns -2.
28
符合直觉的方法是,每次对栈进行修改操作(push和pop)的时候更新最小值。 然后getMin只需要返回我们计算的最小值即可,
29
top也是直接返回栈顶元素即可。 这种做法每次修改栈都需要更新最小值,因此时间复杂度是O(n).
30
31
-
+
32
33
是否有更高效的算法呢?答案是有的。
34
@@ -50,8 +50,8 @@ pop或者top的时候:
50
51
- 如果栈顶元素大于0,说明它对最小值`没有影响`,上一个最小值就是上上个最小值。
52
53
-
54
-
+
+
55
56
## 关键点
57
0 commit comments