校招提前批-阿里校招提前批

业务中台部一面:

1、算法:两个栈实现队列

import java.util.Stack;
public class twoStackImplementQueue {
    //stack1作为主栈,stack2作为辅助栈
    private Stack<Integer> stack1 = new Stack<Integer>();
    private Stack<Integer> stack2 = new Stack<Integer>();

    //弹入操作直接操作主栈即可
    public void push(int node) {
        stack1.push(node);
    }
    //弹出操作,如果主栈为空,则返回整数最小值
    public int pop() {
        //栈中元素个数为空
        if(stack1.isEmpty()) return Integer.MIN_VALUE;
        //栈中元素不为空
        while(!stack1.isEmpty()){
            stack2.push(stack1.pop());
        }
        int top=stack2.pop();
        while(!stack2.isEmpty()){
            stack1.push(stack2.pop());
        }
        return top;
    }
    //判断队列是否为空
    public boolean isEmpty(){
        return stack1.isEmpty();
    }
    //取队列队头元素,队列不存在元素返回整数最小值
    public int getFront(){
        //队列中没有元素
        if(stack1.isEmpty()) return Integer.MIN_VALUE;
        //栈中元素不为空
        while(!stack1.isEmpty()){
            stack2.push(stack1.pop());
        }
        int top=stack2.peek();
        while(!stack2.isEmpty()){
            stack1.push(stack2.pop());
        }
        return top;
    }
    //获取队列队尾元素
    public int getTail(){
        //队列中没有元素
        if(stack1.isEmpty()) return Integer.MIN_VALUE;
        else return stack1.peek();
    }
    public static void main(String []args){
        //测试
        twoStackImplementQueue queue = new twoStackImplementQueue();
        queue.push(1);
        queue.push(2);
        //queue.push(3);
        System.out.println(queue.pop());
        System.out.println(queue.pop());
        System.out.println(queue.isEmpty());
        System.out.println(queue.getFront());
        System.out.println(queue.getTail());
    }
}

2、实习项目介绍

3、论文介绍

4、https保障通信安全的方式

5、hashmap的实现细节

6、tcp如何保障数据的传输准确

 

业务中台部 二面挂:

1、自我介绍

2、介绍项目,并提问session和cookie的区别

3、悲观锁和乐观锁的区别及实现

4、介绍spring的原理

剩下具体记不清了,面试效果很不好

 

高可用团队一面凉经:

1、算法题

1.判断一个字符串是否是前后对称的结构。
举例,abcba是前后对称的,abcddcba是前后对称,abcfa不是前后对称

public class StringReverseSame {
    public boolean isReverseSame(String s){
        if(s.length()==0)return true;
        for(int i=0;i<s.length()/2;i++){
            if(s.charAt(i)!=s.charAt(s.length()-1-i))return false;
        }
        return true;
    }
    public static void main(String []args){
        StringReverseSame test=new StringReverseSame();
        System.out.println(test.isReverseSame("abccba"));
        System.out.println(test.isReverseSame(""));
        System.out.println(test.isReverseSame("a"));
        System.out.println(test.isReverseSame("abds"));
    }
}
//运行结果
true
true
true
false

2.给定一个字符串以及多个子串,对于在字符串中出现的子串可以多次移除,求多次移除后能够得到的最短字符串长度。

输入: 第一行为一个字符串,第二行为多个子串,字符串长度大于0
输出: 多次移除后能够得到的最短字符串长度

例如:
输入:
"ccdaabcdbb"
["ab","cd"]
输出:
2
解释: 
ccdaabcdbb -> ccdacdbb -> cabb -> cb (length = 2)

输入:
"abcabd"
["ab","abcd"]
输出:
0
解释: 
abcabd -> abcd -> "" (length = 0)

public class CleanChildString {
    public int getReMainByChildString(String input,String[] childs){
        if(input.length()==0 || childs.length==0)return input.length();
        StringBuilder inputSb=new StringBuilder(input);
        boolean flag=false;
        for(String element:childs){
            while(inputSb.indexOf(element)>=0){
                flag=true;
                inputSb.delete(inputSb.indexOf(element),inputSb.indexOf(element)+element.length());
            }
        }
        if(flag)return getReMainByChildString(inputSb.toString(),childs);
        return inputSb.length();
    }
     public int remain=Integer.MAX_VALUE;
    public void getReMainByChildStringPlus(String input,String[] childs){
        if(input.length()==0 || childs.length==0) remain=input.length();
        boolean flag=false;
        int fromIndex=0;
        for(String element:childs){
            fromIndex=0;
            while(input.indexOf(element,fromIndex)>=fromIndex){
                flag=true;
                remain=input.length()-element.length();
                StringBuilder inputSb=new StringBuilder(input);
                inputSb.delete(inputSb.indexOf(element,fromIndex),inputSb.indexOf(element,fromIndex)+element.length());
                fromIndex=input.indexOf(element,fromIndex)+element.length();
                getReMainByChildStringPlus(inputSb.toString(),childs);
            }
        }
        if(flag==false)return;
    }
    public static void main(String []args){
        CleanChildString test=new CleanChildString();
        System.out.println(test.getReMainByChildString("ccdaabcdbb",new String[]{"ab","cd"}));
        System.out.println(test.getReMainByChildString("abcabd",new String[]{"ab","abcd"}));
        test.getReMainByChildStringPlus("abcabd",new String[]{"ab","abcd"});
        System.out.println(test.remain);
        test.getReMainByChildStringPlus("ccdaabcdbb",new String[]{"ab","cd"});
        System.out.println(test.remain);
    }
}
//运行结果
2
2
0
2

2、java中垃圾回收算法,其中新生代内存比例1:1:8的原因,这一块问得很细

3、多线程的问题

4、java内存模型,最近看了这篇博客了解https://mp.weixin.qq.com/s/cXYKJJjdUsnlMWE6yqij0A

5、threadLocal实现原理

6、后面记不太清楚了

总结:阿里的java岗位面试深度大,不同部门对于java的要求侧重点也不一致,高可用团队要求对于java的具体实现细节了解深入,不需要会框架,业务中台部对于java的应用方面要了解深入。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值