首页 > 2022微软暑期实习C+AI上海三面凉经
头像
Bruce943
发布于 2022-02-26 13:40
+ 关注

2022微软暑期实习C+AI上海三面凉经

2022年2月25日13点-13点45
一、英语自我介绍
二、针对简历内容提问
三、算法题
       面试官说手写快排(我一听还有这种好事?),后面来了一句不能用递归(直接痛苦面具)
       说实话,一下子懵了。因为平时写快排都是用递归,非递归真的没有考虑过,想应该用栈来模拟系统栈调用递归的过程,但面试时实在没有头绪
       最后写了一个递归快排,也没能改成非递归
       互相折磨后,面试官说这个会做就会做了,不会就不会了,我们聊点其他的吧(距离折磨结束还有15分钟)后面的聊天也无心恋战了,凉透
       晚上搜了一下,发现有位老哥面试腾讯时,也是leader面,遇到了和我相同的问题懵了,程序员的悲或许是相通的吧,哈哈
class Solution {
    public static void main(String[] args) {
        int[] nums=new int[]{9,1,8,2,7,3};
        Solution.stackQuickSort(nums,0, nums.length-1);
        for (int num:nums){
            System.out.println(num);
        }
    }

    public static void stackQuickSort(int[] nums,int left,int right){
        Stack<Integer> stack=new Stack<>();
        if (left<right){
            stack.push(right);
            stack.push(left);
        }
        while (!stack.isEmpty()){
            int l=stack.pop();
            int r=stack.pop();
            int index=quickSort(nums,l,r);
            if (l<index-1){
                stack.push(index-1);
                stack.push(l);
            }
            if (r>index+1){
                stack.push(r);
                stack.push(index+1);
            }
        }
    }

    public static int quickSort(int[] nums,int left,int right){
        int center=nums[left];
        int i=left;
        int j=right;
        while (i<j){
            while (i<j&&nums[j]>=center)j--;
            while (i<j&&nums[i]<=center)i++;
            int temp=nums[j];
            nums[j]=nums[i];
            nums[i]=temp;
        }
        nums[left]=nums[i];
        nums[i]=center;
        return i;
    }
}
平心而论,微软的这次终面难度确实不高,奈何自己的基础实在薄弱
微软是我面的第一家公司,从简历投递,到笔试,到三面,也算是走了个完整的流程,离终点就差一口气,遗憾是肯定的,主要还是自己能力不行,怪不得谁
西班牙队从头再来吧!难道向上攀爬的那条路,不是比站在顶峰更让人热血澎湃吗?——贺炜
       

更多模拟面试

全部评论

(10) 回帖
加载中...
话题 回帖
历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐