题解 | 叠罗汉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;

    }
};

全部评论

相关推荐

10-09 19:08
已编辑
门头沟学院 Java
后端转测开第一人:换个模版 技术栈写的精炼紧凑一点 多投就行
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务