华为2023年od面试流程

一、机考(385分)-- 2023年8月1日

1.1、单词接龙

题目描述 


单词接龙的规则是:
。可用于接龙的单词首字母必须要前一个单词的尾字母相同
当存在多个首字母相同的单词时,取长度最长的单词,如果长度也相等,则取字典序最小的单词:已经参与接龙的单词不能重复使用。
现给定一组全部由小写字母组成单词数组,并指定其中的一个单词作为起始单词,进行单词接龙,
请输出最长的单词串,单词串是单词拼接而成,中间没有空格


输入描述


输入的第一行为一个非负整数,表示起始单词在数组中的索引k,0 <= K < N输入的第二行为一个非负整数,表示单词的个数N;
接下来的N行,分别表示单词数组中的单词
备注:
        单词个数N的取值范围为[1.20];

       单个单词的长度的取值范围为[1,30];

输出描述

输出一个字符串,表示最终拼接的单词串

用例一

输入: 

0
6
word
dd
da
dc
dword
d

输出:

worddwordda

说明:

        先确定起始单词word,再接以d开头的且长度最长的单词dword,剩余以d开头且长度最长的有dd、da、dc,则取字典序最小的da,所以最后输出worddwordda。

用例二

输入: 

4
6
word
dd
da
dc
dword
d

输出:

worddwordda

说明:

       先确定起始单词dword,剩余以d开头且长度最长的有dd、da.dc,则取字典序最小的da,所以最后输出dwordda。

java代码

注:考试时读了题就一股脑写下去了,可能代码比较繁琐,通过率只有85%,尝试修改了几个边界值都没用参考下思路吧

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int startIndex = sc.nextInt();
        int n = sc.nextInt();
        sc.nextLine();
        String[] words = new String[n];
        for (int i = 0; i < n; i++) {
            words[i] = sc.nextLine();
        }
        boolean[] used = new boolean[n];
        used[startIndex] = true;
        int usedCount = 1;
        String head = words[startIndex];
        String headEnd = head.substring(head.length() - 1);
        StringBuilder sb = new StringBuilder(head);
        while (usedCount < words.length) {
            List<String> strList = new ArrayList<>();
            // 最长的 字典最小
            for (int i = 0; i < n; i++) {
                if (!used[i] && headEnd.equals(words[i].substring(0, 1))) {
                    strList.add(words[i]);
                }
            }
            if (strList.size() >0) { //说明有
                String str = findStr(strList); //找到正确的
                if(str.length()>1) {
                    headEnd = str.substring(str.length() - 1);
                }
                else {
                    headEnd = str;
                }
                sb.append(str);
                for (int i = 0; i < words.length; i++) {
                    if (str.equals(words[i])){
                        used[i] = true;
                        usedCount++;
                    }
                }
            } else {
                break;
            }
        }
        System.out.println(sb);
    }

    static String findStr(List<String> strList) {
        String temp = strList.get(0);
        for (String str :strList) {
            if (str.length() > temp.length()) {
                temp = str;
            }
            else if (str.length() == temp.length()) {
                char[] strArray = str.toCharArray();
                char[] tempArray = temp.toCharArray();
                for (int i = 0; i < str.length(); i++) {
                    if (strArray[i] != tempArray[i]) {
                        temp =  strArray[i] <tempArray[i] ?str:temp;
                        break;
                    }
                }
            }
        }
        return  temp;

 1.2、阿里巴巴找黄金宝箱(III)

题目描述 

贫如洗的樵夫阿里巴巴在去砍柴的路上,无意中发现了强盗集团的藏宝地,藏宝地有编号从0-N的箱子,每个箱子上面贴有一个数字。
阿里巴巴念出一个咒语数字,查看宝箱是否存在只 两个不同箱子,这两个箱子上贴的数字相同,同时这两个箱了的编号之差的绝对值小于等于咒语数字,如果存在这样的一对宝箱,请返回最先找到的那对宝箱左边箱子的编号,如果不存在则返回-1


输入描述

第一行输入一个数字字串,数字之间使用逗号分隔,例如: 1,2,3,1

1s字串中数字个数 ≤100000
-100000≤每个数字值≤100000


第二行输入咒语数字,例如: 3
1≤咒语数字 ≤100000

输出描述

存在这样的一对宝箱,请返回最先找到的那对宝箱左边箱子的编号,如果不存在则返回-1

用例一

输入: 

6,3,1,6
3

输出:

1

用例二

输入: 

5,6,7,5,6,7
2

输出:

-1

说明:

       不存在 距离都是3 所以输出-1

java代码

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String boxeLine = sc.nextLine();
        int zhou = sc.nextInt();
        String[] boxes = boxeLine.split(",");
        boolean findBox = false;
        for (int i = 0; i < boxes.length; i++) {
            int box1 = Integer.parseInt(boxes[i]); //数字 ,编号是索引
            if (findBox) {
                break;
            }
            for (int j = i+1; j < boxes.length; j++) {
                int box2 = Integer.parseInt(boxes[j]);
                if (box1==box2 && Math.abs(i-j) <= zhou) {
                    findBox = true;
                    System.out.println(i);
                    break;
                }
            }
        }
        if (!findBox) {
            System.out.println(-1);
        }
    }

 1.3、最长方连续方波信号

题目描述 

输入一串方波信号,求取最长的完全连续交替方波信号,并将其输出如果有相同长度的交替方波信号,输出任一即可方波信号高位用1标识,低位用0标识,如图:

 说明:
1.一个完整的信号一定以0开始然后以0结尾,即010是一个完整信号,但101,1010,0101不是2.输入的一串方波信号是由一个或多个完整信号组成
3.两个相邻信号之间可能有0个或多个低位,如0110010,011000010
4.同一个信号中可以有连续的高位,如01110101011110001010,前14位是一个具有连续高位的信
5.完全连续交替方波是指10交替,如01010是完全连续交替方波,0110不是


输入描述

输入信号字符串 (长度 >= 3 且 <= 1024)0010101010110000101000010注: 输入总是合法的,不用考虑异常情况

输出描述

输出最长的完全连续交替方波信号串: 01010若不存在完全连续交替方波信号串,输出 -1。

用例一

输入: 

00101010101100001010010

输出:

01010

说明:

输入信号串中有三个信号!0 010101010110(第一个信号段)00 01010(第二个信号段)010(第三个信号段)第一个信号虽然有交替的方波信号段,但出现了11部分的连续高位,不算完全连续交替方波在剩下的连续方波信号串中01010最长

java代码

这到底是按照网上的思路解答的

public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String line = sc.nextLine();
       String res = findResult(line);
       System.out.println(res);
    }

    public static String findResult (String line){
        Pattern reg = Pattern.compile("^(01)+0$");
        int maxLen = 0;
        String result = "-1";
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < line.length(); i++) {
            char ch = line.charAt(i);
            if (ch == '0') {
                if (buffer.length() > 0 && buffer.charAt(buffer.length() - 1) == '0') {
                    if (reg.matcher(buffer.toString()).find() && buffer.length() > maxLen) {
                        result = buffer.toString();
                        maxLen = buffer.length();
                    }
                    buffer = new StringBuffer();
                }
            }
            buffer.append(ch);
        }
        if (buffer.length() > 0) {
            if (reg.matcher(buffer.toString()).find() && buffer.length() > maxLen) {
                return buffer.toString();
            }
        }
        return result;
    }
}

二、性格测试 --2023年8月2日

会有一个链接,点进去答题就行

这是个他们采用性格测评的一些说明,其实仔细看挺有用,对于认识自己

华为社会招聘心理综合测评攻略

三、技术一面--2023年8月7日

整体流程都是自我介绍+具体技术问题及项目细节+手撕代码

手撕代码

    题目

        给定一个含有n个正整数的数组和一个正整数s ,找出该数组中满足其和≥ s 的长度最小的连续子数组。如果不存在符合条件的连续子数组,返回0。示例:
输入: s = 7, nums = [2,3,1,2,4,3]
输出: 2
解释: 子数组[4,3] 是该条件下的长度最小的连续子数组。

java代码实现

 xdm注意审题,我看错题了,直接写劈叉了。。。。

// 双指针
	int findMinLength(int[] nums, int s) {
        int begin = 0;
        int end = 0;
        int sum = 0;
        int res = Integer.MAX_VALUE;
        while (end < nums.length) {
            sum += nums[end];
            while (sum >= s) {
                res = Math.min(res, end-begin+1);
                sum -= nums[begin++];
            }
            end++;
        }

        return res == Integer.MAX_VALUE ? 0 :res;

四、技术二面--2023年8月8日

手撕代码

    题目

 给定一个保存员工信息的数据结构,它包含了员工唯一的id,重要度 和 直系下属的id。
 比如,员工1是员工2的领导,员工2是员工3的领导。他们相应的重要度为15, 10, 5。
 那么员工1的数据结构是[1, 15, [2]],员工2的数据结构是[2, 10, [3]],员工3的数据结构是[3, 5, []]。
 注意虽然员工3也是员工1的一个下属,但是由于并不是直系下属,因此没有体现在员工1的数据结构中。
 现在输入一个公司的所有员工信息,以及单个员工id,返回这个员工和他所有下属的重要度之和。

 示例:
 输入: [[1, 5, [2, 3]], [2, 3, []], [3, 3, []]], 1
 输出: 11
 解释:
 员工1自身的重要度是5,他有两个直系下属2和3,而且2和3的重要度均为3。因此员工1的总重要度是 5 + 3 + 3 = 11。
 备注:不需要用Scanner解析输入的字符串,直接构造员工对象即可

java代码实现

直接用迭代就行了

public static void main(String[] args) {
        String id = "1"; // 初始值

        Employ employ2 = new Employ();
        employ2.setId("2");
        employ2.setScore(3);

        List<Employ> employList3 = new ArrayList<>();
        Employ employ4 = new Employ();
        employ4.setId("4");
        employ4.setScore(2);
        employList3.add(employ4);

        Employ employ3 = new Employ();
        employ3.setId("3");
        employ3.setScore(3);
        employ3.setEmployList(employList3);

        List<Employ> employList = new ArrayList<>();
        employList.add(employ2);
        employList.add(employ3);

        Employ employ = new Employ();
        employ.setId("1");
        employ.setScore(5);
        employ.setEmployList(employList);

        // 计算
        int[] allScore = {0};
        colcScore(employ3, allScore);
        System.out.println(allScore[0]);

    }

    public  static  void colcScore(Employ employ,  int[] allScore) {
        allScore[0] = allScore[0]+ employ.getScore();
        List<Employ> list = employ.getEmployList();
        if (list == null ) {
            return;
        }
        for (Employ ee : list) {
            colcScore(ee,  allScore);
        }
    }

这是个dto类

public class Employ {
    String id;
    int score;
    
    List<Employ> employList;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public List<Employ> getEmployList() {
        return employList;
    }

    public void setEmployList(List<Employ> employList) {
        this.employList = employList;
    }

五、资面--2023年8月9日

就谈了半个小时,还是继续自我介绍 偏重你个职场经历 个人现在情况 地址 期望薪资啥的,表现积极乐观点就行了

六、主管面--2023年8月10日

这个给我面的不太会了,完事跟科锐的HR沟通,他说是压力测试。。。。

但是客观的讲 面试管是一个就特别资深的华为人吧,有讨论到目标+自律方面 是比较值的吸收的,毕竟资深职场人,又是前辈,剩下的就是有点压力测试(关于抗压,你随便压,咱换个场地,随便辩论,你别挂着offer辩论,这样我也不敢大声bb,哈哈)。

七、后续

    总结一下吧,应该是过了个周末,(8月14)告诉定级了;

    然后提前准备各种材料,中间有些曲折,断断续续搞了一周(2023年8月14--8月20)材料+offer审批;

    本周一应该到8月21了,offer邮件下来了,约定周四入职,然后就提交之前准备的材料,按部就班就行

    明天入职,就这样吧。

    ---------------------------------------------- end --------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值