1.序

马上春招了,分享一波干货。腾讯、百度、阿里、京东、快手、斗鱼、华为、海康威视等面试过程。昨天分享了网易雷火,今天来看看阿里。

在面试之前给大家看看我的简历以及个人简介部分,因为面试过程与自己的简历有很大关系。面试官往往会结合简历以及个人简介来问。

2.阿里面试过程

2.1阿里1面 (部门:飞猪java开发、时间:45分钟)

1 A题
替换字符串中的通配符?

给定字符串(合法字符只包括0,1,?)替换字符串中的通配符?为0或 者1,生成所有可能的字符串。

Input str = “1??0?101”

Output:

10000101
10001101
10100101
10101101
11000101
11001101
11100101
11101101

其实这道题用到了深度优先搜索,深度优先搜索呢是这样的,建立在图上的数据结构,是图的搜索算法之一,在深度优先搜索算法中,每条边最多会被访问两次,一次是遍历,一次是回退。回溯的过程,然后所以时间复杂度是 O(E)。它的空间复杂度因为递归函数调用不会栈的深度不会超过顶点的个数,所以深度优先搜索的空间复杂度为 O(V)。

public class Test22 {
        public static void main(String[] args){
            String s = "1??0?101";
            System.out.println(generateString(s));
        }
        private static List<String> result;
        private static char[] sc;

        public static List<String> generateString(String s) {
            result = new ArrayList<>();
            sc = s.toCharArray();
            helper(0);
            return result;
        }

        private static void helper(int index) {
            if (index == sc.length) {
                result.add(new String(sc));
                return;
            }
            if (sc[index] == '?') {
                sc[index] = '0';
                helper(index + 1);
                sc[index] = '1';
                helper(index + 1);
                sc[index] = '?';
            } else {
                helper(index + 1);
            }
        }

    }

2 A题

给定两个二叉树,编写一个函数来检验它们是否相同。

如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。

示例 1:

输入: 1 1
/ \ / \

2 3 2 3

结果 [1,2,3], [1,2,3]输出: true

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
 
 
 //方式1
class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && p == null) {
          return true;
        }
        if (p == null || q == null) {
          return false;
        }
 
        if (p.val != q.val) {
          return false;
        }
        return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
}


 //方式2
 class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p == null && q == null){
            return true;
        }
        if (p != null && q != null && p.val == q.val){
            return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
        }
        return false;
    }
}


//方式3
public boolean isSameTree(TreeNode p, TreeNode q) {
        Queue<TreeNode> queue=new LinkedList<>();
        queue.add(p);
        queue.add(q);//两个树的节点进队列
        while(!queue.isEmpty()){
            TreeNode f=queue.poll();//出队列,如果队列头为空,返回null
            TreeNode s=queue.poll();
            if(f==null&&s==null) continue;
            else if(f == null || s == null || f.val != s.val) return false;
            queue.add(f.left);
            queue.add(s.left);
            queue.add(f.right);
            queue.add(s.right);
        }
        return true;
    }

2垃圾回收

(G1和CMS区别)

(分代回收算法)

(GC回收机制(垃圾回收器经典算法)(JVM中内存区域的划分)(GC收集器有哪些))

CMS那一块具体看jvm书籍

点击 你们要的免费书来了 获取jvm书

3 集合

4看过java方面的书籍

你们要的免费书来了

5编码的艺术(阿里人的一丝不苟

讲解自己对代码的认真。

6 项目

个人简历:梦想成真-----项目自我介绍

3.阿里面试感受

  • 阿里的笔试很难
  • 建议阿里准备好了再投递,而且建议找师兄师姐内推,不要随便相信阿里hc很多。
  • 阿里的面试很重视深度优先、广度优先搜索和动态规划,所以建议好好复习一下。
  • 阿里的面试中很重视场景题,但是不要害怕,只要尽量往那边靠就行,可以在面试前多看看阿里面经中的场景题。
  • 阿里的面试大部分也是一周一次。所以期间不断的复习。