9.13微众银行笔试

题目不记得了,贴个代码吧

第一题

package one;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        LinkedHashSet<Integer> set = new LinkedHashSet<>();
        for (int i = n - 1; i >= 0; i--) {
            if(set.contains(a[i])){
                continue;
            }
            set.add(a[i]);
        }
        ArrayList<Integer> ans = new ArrayList<>(set);
//        System.out.println(ans);
        for (int i = ans.size() - 1;  i >= 0; i--) {
            System.out.print(ans.get(i) + " ");
        }
    }
}

第二题

package two;

import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LinkedList<Integer> list = new LinkedList<>();
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            list.addLast(sc.nextInt());
        }
        while (!list.isEmpty()){
            Integer first = list.removeFirst();
            System.out.print(first + " ");
            if(list.isEmpty()){
                break;
            }
            list.addLast(list.removeFirst());
        }
    }
}

第三题

思路:两个 set,一个保存起点能到的点,一个人保存终点能到的点。然后取交集,若交集不为空,求组合数 Cn2,若交集为空答案就是两个 set.size() 的乘积

package three;

import java.util.*;
/*
3 2 1 3
1 2
2 3
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int s = sc.nextInt();
        int t = sc.nextInt();
        HashMap<Integer, LinkedList<Integer>> graph = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            graph.putIfAbsent(x, new LinkedList<>());
            graph.get(x).add(y);
            graph.putIfAbsent(y, new LinkedList<>());
            graph.get(y).add(x);
        }
        HashSet<Integer> start = new HashSet<>();
        
        HashSet<Integer> end = new HashSet<>();
        
        HashSet<Integer> visit = new HashSet<>();
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        start.add(s);
        queue.add(s);
        while (!queue.isEmpty()) {
            Integer head = queue.pollFirst();
            visit.add(head);
            start.add(head);
            LinkedList<Integer> nexts = graph.get(head);
            if(nexts== null){
                break;
            }
            for (Integer next : nexts) {
                if (visit.contains(next)) {
                    continue;
                }
                queue.addLast(next);
                visit.add(next);
            }

        }
        queue = new ArrayDeque<>();
        visit = new HashSet<>();
        end.add(t);
        queue.add(t);
        while (!queue.isEmpty()) {
            Integer head = queue.pollFirst();
            visit.add(head);
            end.add(head);
            LinkedList<Integer> nexts = graph.get(head);
            if(nexts== null){
                break;
            }
            for (Integer next : nexts) {
                if (visit.contains(next)) {
                    continue;
                }
                queue.addLast(next);
                visit.add(next);
            }

        }
//        System.out.println(start);
//        System.out.println(end);
        HashSet<Integer> tmp = new HashSet<>(start);
        boolean flag = tmp.retainAll(end);
        int ans = 0;
        if(!flag){
            //组合数Cn2
            ans = n * (n - 1) / 2;

        }else {
            ans = start.size() * end.size();
        }
        System.out.println(ans);

    }
}

#微众银行#
全部评论

相关推荐

bg双非本科,方向是嵌入式。这次秋招一共拿到了&nbsp;8&nbsp;个&nbsp;offer,最高年包&nbsp;40w,中间也有一段在海康的实习经历,还有几次国家级竞赛。写这篇不是想证明什么,只是想把自己走过的这条路,尽量讲清楚一点,给同样背景的人一个参考。一、我一开始也很迷茫刚决定走嵌入式的时候,其实并没有一个特别清晰的规划。网上的信息很零散,有人说一定要懂底层,有人说项目更重要,也有人建议直接转方向。很多时候都是在怀疑:1.自己这种背景到底有没有机会2.现在学的东西到底有没有用3.是不是已经开始晚了这些问题,我当时一个都没答案。二、现在回头看,我主要做对了这几件事第一,方向尽早确定,但不把自己锁死。我比较早就确定了嵌入式这个大方向,但具体做哪一块,是在项目、竞赛和实习中慢慢调整的,而不是一开始就给自己下结论。第二,用项目和竞赛去“证明能力”,而不是堆技术名词。我不会刻意追求学得多全面,而是确保自己参与的每个项目,都能讲清楚:我负责了什么、遇到了什么问题、最后是怎么解决的。第三,尽早接触真实的工程环境。在海康实习的那段时间,对我触动挺大的。我开始意识到,企业更看重的是代码结构、逻辑清晰度,以及你能不能把事情说清楚,而不只是会不会某个知识点。第四,把秋招当成一个需要长期迭代的过程。简历不是一次写完的,面试表现也不是一次就到位的。我会在每次面试后复盘哪些问题没答好,再针对性补。三、我踩过的一些坑现在看也挺典型的:1.一开始在底层细节上纠结太久,投入产出比不高2.做过项目,但前期不会总结,导致面试表达吃亏3.早期有点害怕面试,准备不充分就去投这些弯路走过之后,才慢慢找到节奏。四、给和我背景相似的人一点建议如果你也是双非,准备走嵌入式,我觉得有几件事挺重要的:1.不用等“准备得差不多了”再投2.项目一定要能讲清楚,而不是做完就算3.不要只盯着技术,多关注表达和逻辑很多时候,差的不是能力,而是呈现方式。五、写在最后这篇总结不是标准答案,只是我个人的一次复盘。后面我会陆续把自己在嵌入式学习、竞赛、实习和秋招中的一些真实经验拆开来讲,希望能对后来的人有点帮助。如果你正好也在这条路上,希望你能少走一点弯路。
x_y_z1:蹲个后续
点赞 评论 收藏
分享
2025-12-15 12:50
河北工程大学
sta666:我也是这个国际商业化的,三天,一天一面,就通过了,不过我是后端实习生,好好面感觉能过。
点赞 评论 收藏
分享
评论
1
6
分享

创作者周榜

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