题解 | 叠罗汉I
叠罗汉I
https://www.nowcoder.com/practice/3c2451031d024387a0f44dcab77a8abc
#include <vector>
class Stack {
public:
int getHeight(vector<int> men, int n) {
// write code here
vector<int> dp(n,1);
int max_height =0;
for(int i=1;i<n;++i){
for(int j =0;j<i;++j){
if (men[i]>men[j]) {
dp[i]= max(dp[i], dp[j]+1);
}
}
max_height = max(max_height, dp[i]);
}
return max_height;
}
};