From 1ada4ba0f0e97a695bb7ef69dd841f775954ce2b Mon Sep 17 00:00:00 2001 From: jianghe_47 <571326935@qq.com> Date: Sun, 28 Sep 2025 19:13:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E5=91=A8=E7=BB=83?= =?UTF-8?q?=E4=B9=A0=E7=AC=AC=E4=B8=89=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\350\214\203\344\277\256\350\252\211.cpp" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "topic01/submit/LC0084_\350\214\203\344\277\256\350\252\211.cpp" diff --git "a/topic01/submit/LC0084_\350\214\203\344\277\256\350\252\211.cpp" "b/topic01/submit/LC0084_\350\214\203\344\277\256\350\252\211.cpp" new file mode 100644 index 0000000..b70bbbc --- /dev/null +++ "b/topic01/submit/LC0084_\350\214\203\344\277\256\350\252\211.cpp" @@ -0,0 +1,32 @@ +class Solution { +public: + int largestRectangleArea(vector& heights) { + int n = heights.size(); + vector left(n), right(n); + + stack mono_stack; + for (int i = 0; i < n; ++i) { + while (!mono_stack.empty() && heights[mono_stack.top()] >= heights[i]) { + mono_stack.pop(); + } + left[i] = (mono_stack.empty() ? -1 : mono_stack.top()); + mono_stack.push(i); + } + + mono_stack = stack(); + for (int i = n - 1; i >= 0; --i) { + while (!mono_stack.empty() && heights[mono_stack.top()] >= heights[i]) { + mono_stack.pop(); + } + right[i] = (mono_stack.empty() ? n : mono_stack.top()); + mono_stack.push(i); + } + + int ans = 0; + for (int i = 0; i < n; ++i) { + ans = max(ans, (right[i] - left[i] - 1) * heights[i]); + } + return ans; + } +}; + -- Gitee From 9c7a882323963a2d3ea4e0692f8fd1ba1f36da76 Mon Sep 17 00:00:00 2001 From: jianghe_47 <571326935@qq.com> Date: Sun, 28 Sep 2025 19:39:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E5=9B=9B=E6=AC=A1=E7=BB=83=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\350\214\203\344\277\256\350\252\211.cpp" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "topic01/submit/LC0496_\350\214\203\344\277\256\350\252\211.cpp" diff --git "a/topic01/submit/LC0496_\350\214\203\344\277\256\350\252\211.cpp" "b/topic01/submit/LC0496_\350\214\203\344\277\256\350\252\211.cpp" new file mode 100644 index 0000000..718b11d --- /dev/null +++ "b/topic01/submit/LC0496_\350\214\203\344\277\256\350\252\211.cpp" @@ -0,0 +1,30 @@ +class Solution { +public: + vector nextGreaterElement(vector& nums1, vector& nums2) { + vector sum (nums1.size(),-1); + for(int i=0;i