WeBank笔试

WeBank笔试题目讨论

第一题

没啥好说的应该都过

第二题

第二题我只过了82%不知道为什么,我觉得自己都考虑到了,希望有大神能帮忙解答一下

题目描述:
旋转数组并输出
x为顺时针,y水平反转,z逆时针
package cn.webank;

import java.util.Arrays;
import java.util.Scanner;

public class Demo02 {
    static int m,n;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt()%4;
        int y = scanner.nextInt()%2;
        int z = scanner.nextInt()%4;

        n = scanner.nextInt();
        m = scanner.nextInt();

        int Q = scanner.nextInt();

        Point[] res=new Point[Q];

        for (int i = 0; i < Q; i++) {
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();

            Point p=new Point(x1,y1);
            for (int j = 0; j < x; j++) {
                p=rotateX(p.x,p.y);
                int temp=m;
                m=n;
                n=temp;
            }

            for (int j = 0; j < y; j++) {
                p=rotateY(p.x,p.y);
            }

            for (int j = 0; j < z; j++) {
                p=rotateZ(p.x,p.y);
                int temp=m;
                m=n;
                n=temp;
            }

            res[i]=p;

        }

        Arrays.stream(res).forEach(each-> System.out.println(each.x+" "+each.y));






    }
    public static Point rotateX(int x,int y){
        return new Point(y,n-x+1);
    }

    public static Point rotateZ(int x,int y){
        return new Point(m-y+1,x);
    }

    public static Point rotateY(int x,int y){
        return new Point(x,m-y+1);
    }


}

class Point{
    int x;
    int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}


第三题

第三题代码我只过了18%
package cn.webank;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=scanner.nextInt();
        }
        int[] res=new int[n];
        for (int i = 0; i < n; i++) {
            res[i]=numXiaoyu(arr,res,i);
        }
        long count=0;
        for (int i = 0; i < n; i++) {
            if (res[i]<2){
                continue;
            }
            if (res[i]==2){
                count++;
            }else {
                count+=res[i]*(res[i]-1)/2;
            }
        }
        System.out.println(count);

    }

    public static int numXiaoyu(int[] arr,int[] res,int index){
        if (index==0){
            return 0;
        }
        for (int i = index-1; i >= 0 ; i--) {
            if (arr[index]>=arr[i]){
                return res[i]+1;
            }
        }
        return 0;
    }
}

主要的想法是动态规划,记录比自己小的数字的数量,并根据数量进行统计,2能够贡献1,更大的数贡献x*(x-1)/2,但是结果只能跑通18%,好像还是6的特殊情况🤐求助呀求助


#笔试题型##微众银行#
全部评论

相关推荐

11-02 20:28
门头沟学院 Java
也是实习转正,已oc行云集团&nbsp;一面1.自我介绍2.自选cursor/Claude&nbsp;code/idea&nbsp;ai编程插件,在线投屏完成编程题目:3.项目中,线程池的作用4.用了线程池和不用线程池区别5.线程池的构造方法有哪些参数,作用6.拒绝策略有哪些7.AQS原理8.基于AQS实现的类9.CAS原理,会出现的问题,ABA10.有哪些加锁的方式11.ReentrantLock和@synchronized区别12.JVM分为哪些内存区域13.使用过的数据库有哪些14.索引有哪些类型15.加索引一定会生效吗16.事务的特性17.开启事务的方法18.什么情况下事务会失效,先开启事务还是先开启锁,反过来会有什么问题19.慢接口如何排查优化反问:公司技术栈,负责的业务,对面试的评价项目和实习都没怎么问,ai开发的题目挺简单的,前面边ai开发会边问常用的mcp,还有prompt怎么写的,平时怎么使用的,配置在哪里,有没有了解过Subagent,ai的问题比较多,但是都挺简单的————————————————————行云集团&nbsp;二面1.自我介绍2.学校经历3.一面没答出的问题重新回答4.根据面试官投屏的代码,说有什么问题:(有5-6张图,应该是面试官根据简历项目生成的ai代码,就是去看代码逻辑有什么问题)缓存过期时间没设置,线程池没关闭,临时文件没清理,线程池配置,无界队列,异常没抛出捕获;然后是方案选择,就是对着选择的方案说异步高并发相关知识什么的了5.面试官给开源项目,展示一下用什么方式熟悉项目的6.常用的ai工具7.Claude模型的区别8.Ai最近有什么新特性9.了解最新技术的渠道————————————————————行云集团&nbsp;三面1.自我介绍2.实习经历介绍3.给一万个用户发短信,怎么设计,中途宕机了怎么解决4.共享电脑屏幕看一下之前写的项目代码,问代码为什么要这么设计5.Post和get请求区别6.http状态码&nbsp;301,302什么意思,场景是什么7.redis用法8.高并发抢购场景怎么设计,怎么防止超卖9.反问————————————————————行云集团&nbsp;四面&nbsp;hr面就是到岗时间还有转正意向什么的经典问题
点赞 评论 收藏
分享
评论
1
2
分享

创作者周榜

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