码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-01-05 01:23:21      阅读:162      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!