Skip to content

Commit 77425c5

Browse files
committed
完成496
1 parent 91cfae7 commit 77425c5

19 files changed

+88
-15
lines changed

README.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3985,15 +3985,15 @@ TIP: **公众号的微信号是: `jikerizhi`**。__因为众所周知的原因
39853985
//|{doc_base_url}/0495-teemo-attacking.adoc[题解]
39863986
//|Medium
39873987
//|
3988-
//
3989-
//|{counter:codes}
3990-
//|496
3991-
//|{leetcode_base_url}/next-greater-element-i/[Next Greater Element I]
3992-
//|{source_base_url}/_0496_NextGreaterElementI.java[Java]
3993-
//|{doc_base_url}/0496-next-greater-element-i.adoc[题解]
3994-
//|Easy
3995-
//|
3996-
//
3988+
3989+
|{counter:codes}
3990+
|496
3991+
|{leetcode_base_url}/next-greater-element-i/[Next Greater Element I]
3992+
|{source_base_url}/_0496_NextGreaterElementI.java[Java]
3993+
|{doc_base_url}/0496-next-greater-element-i.adoc[题解]
3994+
|Easy
3995+
|
3996+
39973997
//|{counter:codes}
39983998
//|497
39993999
//|{leetcode_base_url}/random-point-in-non-overlapping-rectangles/[Random Point in Non-overlapping Rectangles]

docs/0000-23-monotonic-stack.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
. xref:0084-largest-rectangle-in-histogram.adoc[84. Largest Rectangle in Histogram]
88
. xref:0503-next-greater-element-ii.adoc[503. Next Greater Element II]
99
. xref:0042-trapping-rain-water.adoc[42. Trapping Rain Water]
10+
. xref:0496-next-greater-element-i.adoc[496. Next Greater Element I]
1011

1112
== 参考资料
1213

1314
. https://cloud.tencent.com/developer/article/1998273[单调栈详解及其LeetCode应用详解^]
14-
.
15+
. https://blog.csdn.net/weixin_50348837/article/details/136304458[深入理解单调栈算法,这一篇就够了^]

docs/0000-data-structure-list.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
. xref:1094-car-pooling.adoc[1094. Car Pooling]
1515
. xref:1109-corporate-flight-bookings.adoc[1109. Corporate Flight Bookings]
1616

17+
=== 单调栈
18+
19+
详情见 xref:0000-23-monotonic-stack.adoc[Monotonic Stack 单调栈]
20+
21+
1722

1823
== 参考资料
1924

docs/0496-next-greater-element-i.adoc

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ https://leetcode.com/problems/next-greater-element-i/[LeetCode - Next Greater El
66

77
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`.
88
9-
10-
119
The Next Greater Number of a number *x* in `nums1` is the first greater number to its right in `nums2`. If it does not exist, output -1 for this number.
1210
1311
1412
*Example 1:*
1513
16-
1714
[subs="verbatim,quotes,macros"]
1815
----
1916
*Input:* *nums1* = [4,1,2], *nums2* = [1,3,4,2].
@@ -27,7 +24,6 @@ The Next Greater Number of a number *x* in `nums1` is the first greater number t
2724
2825
*Example 2:*
2926
30-
3127
[subs="verbatim,quotes,macros"]
3228
----
3329
*Input:* *nums1* = [2,4], *nums2* = [1,2,3,4].
@@ -38,13 +34,40 @@ The Next Greater Number of a number *x* in `nums1` is the first greater number t
3834
----
3935
4036
41-
4237
*Note:*
4338
4439
. All elements in `nums1` and `nums2` are unique.
4540
. The length of both `nums1` and `nums2` would not exceed 1000.
4641
42+
== 思路分析
43+
44+
单调栈
45+
46+
image::images/0496-01.png[{image_attr}]
47+
48+
image::images/0496-02.png[{image_attr}]
49+
50+
image::images/0496-03.png[{image_attr}]
51+
52+
image::images/0496-04.png[{image_attr}]
4753
54+
image::images/0496-05.png[{image_attr}]
55+
56+
image::images/0496-06.png[{image_attr}]
57+
58+
image::images/0496-07.png[{image_attr}]
59+
60+
image::images/0496-08.png[{image_attr}]
61+
62+
image::images/0496-09.png[{image_attr}]
63+
64+
image::images/0496-10.png[{image_attr}]
65+
66+
image::images/0496-11.png[{image_attr}]
67+
68+
image::images/0496-12.png[{image_attr}]
69+
70+
image::images/0496-13.png[{image_attr}]
4871
4972
5073
[[src-0496]]
@@ -53,3 +76,8 @@ The Next Greater Number of a number *x* in `nums1` is the first greater number t
5376
include::{sourcedir}/_0496_NextGreaterElementI.java[]
5477
----
5578
79+
== 参考资料
80+
81+
. https://leetcode.cn/problems/next-greater-element-i/solutions/1065517/xia-yi-ge-geng-da-yuan-su-i-by-leetcode-bfcoj/[496. 下一个更大元素 I - 官方题解^]
82+
. https://leetcode.cn/problems/next-greater-element-i/solutions/2820648/shi-pin-dan-diao-zhan-de-liang-chong-xie-ri0i/[496. 下一个更大元素 I - 单调栈的两种写法,附单调栈题单^]
83+

docs/images/0496-01.png

71.6 KB
Loading

docs/images/0496-02.png

82.4 KB
Loading

docs/images/0496-03.png

85.4 KB
Loading

docs/images/0496-04.png

82 KB
Loading

docs/images/0496-05.png

101 KB
Loading

docs/images/0496-06.png

87.6 KB
Loading

0 commit comments

Comments
 (0)