diff --git "a/topic01/submit/LC1944_\346\235\250\347\216\211\345\256\235.cpp" "b/topic01/submit/LC1944_\346\235\250\347\216\211\345\256\235.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..c7c74f2b60c293cb457b0922950f012a272ff724 --- /dev/null +++ "b/topic01/submit/LC1944_\346\235\250\347\216\211\345\256\235.cpp" @@ -0,0 +1,16 @@ +class Solution { +public: + vector canSeePersonsCount(vector& heights) { + stack s; + vector ans(heights.size()); + for (int i = heights.size() - 1; i >= 0; --i) { + while (s.size() && s.top() < heights[i]) { + ans[i]++; + s.pop(); + } + ans[i] += !s.empty(); + s.push(heights[i]); + } + return ans; + } +}; \ No newline at end of file