2021-华为暑期实习面经

    疫情期间,在家全力备战华为软件精英挑战赛CodeCraft2020,突然某一天收到华为Hr电话,邀请去投暑期实习简历。于是,便误打误撞的投了,经历了笔试,技术面试和主管面试,总体还算简单。面试过程中遇到的笔试和面试题,分享给大家,欢迎来纠正。

笔试题

  1. 字符串全排列(不重复),只对了90%CASE。
    输入:字符串
    输出:全排列个数
    input:
    abcc
    output:
    12
    代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    import java.util.Scanner;

    public class _01_test_1 {
    static char[] arr = null;
    static int count = 0;
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String str = scanner.nextLine();
    arr = str.toCharArray();
    int length = arr.length;
    fullArray(0, length - 1);
    System.out.println(count);
    }

    private static void fullArray(int cursor, int end) {
    if (cursor == end) {
    // System.out.println(Arrays.toString(arr));
    count++;
    } else {
    for (int i = cursor; i <= end; i++) {
    if(!swapAccepted(cursor, i)) {
    continue;
    }
    swap(cursor,i);
    fullArray(cursor + 1, end);
    swap(i, cursor);
    }
    }
    }

    private static boolean swapAccepted(int start, int end) {
    for (int i = start; i < end; i++) {
    if (arr[i] == arr[end]) {
    return false;
    }
    }
    return true;
    }


    //将a[]中的a[x] 与 a[y]的值互换
    public static Boolean swap(int x,int y)
    {
    if(arr[x] == arr[y]) {
    return false;
    } else {
    char temp = arr[x];
    arr[x]=arr[y];
    arr[y]=temp;
    }
    return true;
    }
    }
  2. 对一个字符串M去除K个字符,返回最小字典序的那种结果。50%case(代码有些骗分的嫌疑,时间有限,只能这么做)
    input:
    bacaa
    1
    output:
    acaa
    代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    import java.util.Scanner;
    import java.util.TreeSet;

    public class _02_test2_50 {

    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String M = scanner.nextLine();
    int k = scanner.nextInt();
    int length = M.length();
    //移除操作
    TreeSet<String> treeSet = new TreeSet<String>();
    StringBuilder sb = null;
    int end = length-k+1;
    for(int i=0;i<end;i++) {
    sb = new StringBuilder();
    M.substring(i, i+k);
    sb.append(M.substring(0,i));
    sb.append(M.substring(i+k));
    treeSet.add(sb.toString());
    }
    for(String s:treeSet) {
    System.out.println(s);
    break;
    }
    }

    }

3.题目描述:AC 44.4%

  • N个城市,单行道相通
  • 每条道有两个属性:长度、花费。
  • 找从城市1到城市N的最短路径,且够花费。
  • 输入:
  • 金钱K
  • 城市总数N
  • 道路总数R
  • S源 D目 L长度 T花费
  • */
    input:
    5
    6
    7
    1 2 2 4
    2 4 3 3
    3 4 2 4
    1 3 4 1
    4 6 2 1
    3 5 2 0
    5 4 3 2
    output:
    11
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Scanner;
    import java.util.Set;

    public class _03_test {
    public static int allLength=0;
    public static int allSum = 0;
    public static int K = 0;
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    //硬币数
    K = scanner.nextInt();
    //城市总数
    int N = scanner.nextInt();
    //道路总数
    int R = scanner.nextInt();
    ArrayList<Integer> outlist = null;
    ArrayList<Integer> lenList = null;
    ArrayList<Integer> moneyList = null;
    ArrayList<ArrayList<Integer>> allList = null;
    HashMap<Integer,ArrayList<ArrayList<Integer>>> map = new HashMap<Integer, ArrayList<ArrayList<Integer>>>();
    for(int i=0;i<R;i++) {
    int S = scanner.nextInt();
    int D = scanner.nextInt();
    int L = scanner.nextInt();
    int T = scanner.nextInt();
    if(map.get(S)==null) {
    allList = new ArrayList<ArrayList<Integer>>();
    outlist = new ArrayList<Integer>();
    lenList = new ArrayList<Integer>();
    moneyList = new ArrayList<Integer>();
    outlist.add(D);
    lenList.add(L);
    moneyList.add(T);
    allList.add(outlist);
    allList.add(lenList);
    allList.add(moneyList);
    map.put(S, allList);
    }else {
    map.get(S).get(0).add(D);
    map.get(S).get(1).add(L);
    map.get(S).get(2).add(T);
    }
    }
    Set<Integer> set= map.keySet();
    int[] visit = new int[N+1];

    dfs(1,N,map,visit,0,0);
    if(allLength == 0) {
    System.out.println(-1);
    }else {
    System.out.println(allLength);
    }

    }
    public static void dfs(int k,int N,HashMap<Integer,ArrayList<ArrayList<Integer>>> map,int[] visit,int length,int sum) {
    if(k == N) {
    if(sum <= K) {
    allLength = length;
    return ;
    }
    return ;
    }
    visit[k] = 1;
    ArrayList<ArrayList<Integer>> list = map.get(k);
    int outlistLength = list.get(0).size();
    for (int i = 0; i < outlistLength; i++) {
    int gcur = list.get(0).get(i);
    int temp_len = list.get(1).get(i);
    int temp_sum = list.get(2).get(i);
    if(visit[gcur] == 0) {
    length += temp_len;
    sum += temp_sum;
    dfs(gcur,N, map,visit,length,sum);
    length -= temp_len;
    sum -= temp_sum;
    }
    }
    visit[k] = 0;
    }

    }

面试题-技术面

自我介绍
讲项目(我回答的华为软件精英挑战赛和数学建模大赛)
说一下 深度优先搜索、常见的排序算法
Java 异常的类型、多线程实现的方法、线程池的作用、拷贝(深拷贝/浅拷贝)、泛型(描述一下其作用)、反射机制、运行时的数据区域
设计模式???
网络知识:UDP和TCP的区别
数据库知识:连接(自然连接、左连接、右连接)
手撕代码:给两个圆的圆心和半径,判断两个圆是否相交

面试题-主管面

简单的自我介绍
为什么参加这么多比赛?
职业生涯的规划
父母的职业
你在学校目前压力大吗
你有什么想问我的吗?
总体感觉:面试官相对友好

总结

笔试总分600分,得分323.3,100分即可及格。
面试技术官 感觉比较高冷,整体顺利
面试主管官 相对友好,整体顺利
6月初收到意向通知书,华为实习offer顺利到手。

坚持原创技术分享,您的支持将鼓励我继续创作!