题解 | #Redraiment的走法#

Redraiment的走法

https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        int i = 0;
        int[] arr = new int[n];
        while (i < n) {
            arr[i] = in.nextInt();
            i++;
        }

        int[] step = new int[arr.length];
        for (i = arr.length - 1; i >= 0; i--) {

            int itemMax = 1;
            for (int k = i + 1; k < arr.length; k++) {
                if (arr[i] < arr[k]) {
                    itemMax = Math.max(itemMax, step[k]+1);

                }
            }
            step[i] = itemMax;
        }

        int max = Arrays.stream(step).max().getAsInt();
        System.out.println(max);
        in.close();
    }
}

全部评论

相关推荐

求offer的大角牛:简历写的第一乱,没有突出重点,第二项目太多太杂看不出来有啥核心技术,第三自我评价太多了,第四获得的荣誉没啥含金量,可以不写,反正问题不少
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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