网易雷火笔试8.14 总共过了1.8

第一题 AC
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String sin = sc.nextLine();
        String substringIn = sin.substring(1, sin.length());
        String[] splits = substringIn.split("]");

        int[][] nums = new int[splits.length][];
        for (int i = 0; i < splits.length; i++) {
            splits[i] = splits[i].replace('[', ' ');
            splits[i]=splits[i].replace(']',' ');
            splits[i]=splits[i].replace(',',' ');
            splits[i]= splits[i].replaceAll(" ","");
            int[] ints = new int[splits[i].length()];
            for (int j = 0; j < ints.length; j++) {
                ints[j] = splits[i].charAt(j)-'0';
            }
            nums[i] = ints;
        }
        boolean[] isOpen = new boolean[nums.length];
        isOpen[0] = true;
        openFor(nums,isOpen,0);
        boolean isOpenFull = true;
        for (boolean b : isOpen) {
            if(b==false) isOpenFull = false;

        }
        if (isOpenFull)
        System.out.println("true");
        else
        System.out.println("false");
    }
    public static void openFor(int[][] nums,boolean[] isOpen,int index){
        if(isOpen[index]==true){
            for (int j = 0; j < nums[index].length;j++) {
                if(isOpen[nums[index][j]]==false){
                    isOpen[nums[index][j]] = true;//打开
                    openFor(nums, isOpen, nums[index][j]);
                }

            }
        }
    }

第二题 暴力80%
public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int count=0;
        for (int i = 25; i <=num; i++) {
            String str = String.valueOf(i);
            for (int j = 0; j < str.length()-1; j++) {
                if(str.charAt(j)=='2'&&str.charAt(j+1)=='5'){
                    count++;
                    break;
                }
            }

        }
        System.out.println(count);
    }
第三题题目太长了 没做了 

#网易雷火笔试##网易雷火2023秋招笔试虐我的瞬间#
全部评论
咱俩写的差不多,会不会被判定为作弊😅
点赞 回复 分享
发布于 2022-08-14 16:34
第三题直接return 3能过33%
点赞 回复 分享
发布于 2022-08-14 16:56
字节跳动
校招火热招聘中
官网直投
朋友想问一下,josn输入就硬生生这么处理嘛?
点赞 回复 分享
发布于 2022-08-15 18:56

相关推荐

2 7 评论
分享
牛客网
牛客企业服务