前端社招面经-深圳渐近线科技(一面)已寄

面试流程

  1. 自我介绍
  2. 考察基础数据结构和算法
  3. 算法题的测试

面试题目

  1. 您了解的排序算法有哪些?
  2. 这些排序算法是如何实现的?
  3. 分析一下冒泡排序的时间复杂度?
  4. 详细说一下冒泡排序通过几轮比较来实现排序的。
  5. 按照刚才面试官的思路来分析一下快速排序的时间复杂度
  6. 了解heap内部是如何实现的?构造函数和push函数的时间复杂度是多少?分别详细讲解这两个函数实现了什么,如何得到该时间复杂度?
  7. 堆一般用于实现优先队列,堆化,构建二叉树的结构。
  8. 了解链表吗?做的题是算法题吗?刷了几道?
  9. 通过数组实现一个栈。15分钟✅
  10. 完成二叉树的层序遍历。15分钟✅

算法代码题目

public class Stack {
    public Stack(int length);
    public void Push(int value);
    public int Pop();
    public int Peek();
}
let Stack = function(length){ //先进后出
    this.InQueue = new Array(); 
    this.maxLength = length;
    this.length = this.InQueue.length;
}
Stack.prototype.push = function(num){
    this.InQueue.push(num);
}
Stack.prototype.pop = function(){
    return this.InQueue.pop();
}
Stack.prototype.Peek = function(){
    // 只是获取值,倒数第一个
    return this.InQueue.slice(-1)[0];
}
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number[][]}
 */
var levelOrder = function(root) {
    if(!root) return [];
    const nodeQueue = [root];
    const result = [];
    while(nodeQueue.length){
        let len = nodeQueue.length;
        let resArr = [];
        for(let k = 0; k < len; k++){
            let curNode = nodeQueue.shift();
            if(!!curNode){
                resArr.push(curNode.val);
                if(curNode.left) nodeQueue.push(curNode.left);
                if(curNode.right) nodeQueue.push(curNode.right);
            }
        }
        result.push(resArr);
    }
    return result;
};
#社招##前端##面经#
全部评论
找到了吗题主,感觉算法有点多啊
1 回复 分享
发布于 02-29 14:57 广东
这么多算法的问题啊,感觉这家要求有点高啊
点赞 回复 分享
发布于 2023-03-30 10:00 江苏
德州仪器
校招火热招聘中
官网直投

相关推荐

头像
09-12 16:00
已编辑
山西大学 后端
点赞 评论 收藏
分享
点赞 评论 收藏
分享
2 5 评论
分享
牛客网
牛客企业服务