From 5323109924238d5cdd2e5da97cbf2895376b3fcc Mon Sep 17 00:00:00 2001 From: lijinping <15687781+lijinping0210@user.noreply.gitee.com> Date: Thu, 18 Sep 2025 21:18:05 +0800 Subject: [PATCH] =?UTF-8?q?LC1996=5F=E9=BB=8E=E9=94=A6=E5=9D=AA.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\351\273\216\351\224\246\345\235\252.cpp" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "topic01/submit/LC1944_\351\273\216\351\224\246\345\235\252.cpp" diff --git "a/topic01/submit/LC1944_\351\273\216\351\224\246\345\235\252.cpp" "b/topic01/submit/LC1944_\351\273\216\351\224\246\345\235\252.cpp" new file mode 100644 index 0000000..42e3b85 --- /dev/null +++ "b/topic01/submit/LC1944_\351\273\216\351\224\246\345\235\252.cpp" @@ -0,0 +1,27 @@ +#include +#include +using namespace std; + +class Solution { +public: + vector canSeePersonsCount(vector& heights) { + int n = heights.size(); + vector answer(n, 0); + stack stk; + for (int i = n - 1; i >= 0; --i) { + while (!stk.empty() && heights[i] > heights[stk.top()]) { + answer[i]++; + stk.pop(); + } + if (!stk.empty()) { + answer[i]++; + } + stk.push(i); + } + return answer; + } +}; +int main() { + // 你的程序代码 + return 0; +} -- Gitee