diff --git "a/topic01/submit/LC1944_\351\231\210\350\264\236\347\222\207.cpp" "b/topic01/submit/LC1944_\351\231\210\350\264\236\347\222\207.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..64bed08ec4410e9cfb8bfc6d2ab5e10a6da7b2c1 --- /dev/null +++ "b/topic01/submit/LC1944_\351\231\210\350\264\236\347\222\207.cpp" @@ -0,0 +1,23 @@ +#include +#include +using namespace std; + +class Solution { +public: + vector canSeePersonsCount(vector& heights) { + int n = heights.size(); + vector ans(n); + stack st; + for (int i = n - 1; i >= 0; i--) { + while (!st.empty() && st.top() < heights[i]) { + st.pop(); + ans[i]++; + } + if (!st.empty()) { // 还可以再看到一个人 + ans[i]++; + } + st.push(heights[i]); + } + return ans; + } +}; \ No newline at end of file