首页 > 其他 > 详细

11.7---叠罗汉表演节目(CC150)

时间:2016-01-05 01:22:36      阅读:239      评论:0      收藏:0      [点我收藏+]

1,牛客网第一题:这其实跟找最长递增子序列是一个东西。注意的地方是,返回的是最大的dp,而不是dp[N-1]。

答案:

技术分享
public static int getHeight(int[] men, int n) {
        // write code here
        int res = 0;
        int[] dp = new int[n];
        dp[0] = 1;
        for(int i =1;i <n;i++){
            int max = 0;
            for(int j =0;j < i;j++){
                if(men[j] < men[i]){
                    max = Math.max(max, dp[j]);
                }
            }
            dp[i] = max + 1;
            res = Math.max(res, dp[i]);
        }

        return res;

    }
View Code

 

11.7---叠罗汉表演节目(CC150)

原文:http://www.cnblogs.com/yueyebigdata/p/5100714.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!