25秋招 | 快手一面

  • 项目问题 20min
  • 到这里就开始做题了
  • Q1(5min)

// 数组扁平, 不能用flat;数组排序不能用sort

// 期望输出: [0, 1, 2, 3, 4, 6, 7]

const data = [[[]], [3], [0], 4, [2, 1], [[7, [[[[6]]]]]]];

这题我写了个拍平函数写了个快排

  • Q2:一道输入输出题目(3min)
async function async1() {
  console.log('async1 start');
  await async2();
  console.log('async1 end');
}
async function async2() {
  console.log('async2');
}
console.log('script start');
setTimeout(function() {
  console.log('setTimeout');
}, 0);
async1();
new Promise(function(resolve) {
  console.log('promise1');
  resolve();
}).then(function() {
  console.log('promise2');
});
console.log('script end');
  • Q3:把当前二叉树的右节点移动到左节点的右节点。(15min)
  • 写出来一个有瑕疵的版本,有无大佬可以教一下
function test(root){
    function deal(root, lrNodeTemp) {
        if (!root) {
            return;
        }
        if (!root.left && !root.right) {
            return;
        }
        let rightNode, lrNode;
        if (root.right) {
            rightNode = root.right;
            if (lrNodeTemp === null) root.right = null;
        }
        if (root.left) {
            if (root.left.right) {
                lrNode = root.left.right;
            }
        }
        if (root.left) {
            root.left.right = lrNodeTemp !== null ? lrNodeTemp : rightNode ;
        }
        deal(root.left, lrNode);
    }
    deal(root, null);
    return root;
}

let tree1 = {
    val: "A",
    left:{
        val: "B",
        left:{
            val: "D",
        },
        right:{
            val: "E"
        }
    },
    right:{
        val: "C"
    }
}


let result = test(tree1)
console.log(JSON.stringify(result),'result')

#快手求职进展汇总##九月投秋招是不是太晚了?##软件开发笔面经#
全部评论
太强了
点赞 回复 分享
发布于 2024-08-28 10:36 浙江

相关推荐

哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
真烦好烦真烦:豆包润色了自己没看看吗,再说了,都说豆包是愚蠢且勤快的大学生,ds才是聪明的研究生,怎么敢让豆包写论文的
你们的毕业论文什么进度了
点赞 评论 收藏
分享
半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
评论
5
8
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务