滴滴前端面试分享

16 阅读2分钟

一面

1.如何实现一个全局图片预览,使用js

2.写过mcp吗? mcp常见字段有哪些?

3.问卷编辑器是如何实现 a组件和b组件联动的(因为谈到公司内部的一个问卷调查系统)

4.富文本编辑器定制相关问题(quill)

5.小程序性能优化

6.算法两道

/**
 * 《找到所有祖先》
 *
 * eg1
 * input: test,1, 'name'
 * output: [ 'a' ]
 *
 * input: test, 10, 'name',
 * output: [ 'a', 'b', 'e', 'j' ]
 *
 * input: test, 7, 'id'
 * output: [1, 4, 7]
 */
const test = {
  id: 1,
  name: 'a',
  children: [
    {
      id: 2,
      name: 'b',
      children: [
        {
          id: 5,
          name: 'e',
          children: [
            { id: 8, name: 'h' },
            { id: 9, name: 'i' },
            { id: 10, name: 'j', children: [{ id: 11, name: 'k', children: [{ id: 12, name: 'l' }] }] },
          ],
        },
      ],
    },
    { id: 3, name: 'c' },
    {
      id: 4,
      name: 'd',
      children: [
        { id: 6, name: 'f' },
        { id: 7, name: 'g' },
      ],
    },
  ],
};

function solution1(tree, nodeId, prop) {
   const path = [];
   function dfs(node) {
    if(!node) return false;
    path.push(node[prop]);
    if(node.id === nodeId) return true;
    // 遍历子节点
    const children = Array.isArray(node.children) ? node.children : [];
    for(const child of children) {
      if(dfs(child)) return true; // 向上
    }
    // 没有就弹出
    path.pop();
    return false;
   }
   return dfs(tree) ? path : []
}

console.log(solution1(test,1,'name'))
console.log(solution1(test,10,'name'))
console.log(solution1(test,7,'id'))
/**
 * 《衣服搭配》
 * 小花是个卖衣服的老板,他有一堆上衣和一堆裤子要售卖,上衣裤子尺码均是以身高作为尺码(160,165,175的),
 * 现在他想把同尺码的上衣和裤子搭配成一套来售卖,请帮他从衣服堆中全部找出成套的衣服吧
 *
 * eg1
 * input: [175, 160, 165], [155, 180, 175]
 * output: [175]
 *
 * eg2
 * input: [175, 160, 165, 160], [155, 160, 180]
 * output: [160]
 *
 * eg3
 * input: [175, 160, 165, 160], [170, 160, 160, 165]
 * output: [160, 160, 165]
 *
 * eg4
 * input: [4,9,7], [9,4,9,8,4]
 * output: [4, 9]
 */

function solution(arr1, arr2) {
  const freq = new Map();
  for(const size of arr2) {
    freq.set(size,(freq.get(size) || 0) + 1);
  }

  const res = [];
  for(const size of arr1) {
    const count = freq.get(size) || 0;
    if(count > 0) {
      res.push(size);
      freq.set(size, count-1);
    }
  }
  return res;
}

console.log(solution([175, 160, 165], [155, 180, 175]))
console.log(solution([175, 160, 165, 160], [155, 160, 180]))
console.log(solution([175, 160, 165, 160], [170, 160, 160, 165]))
console.log(solution([4,9,7], [9,4,9,8,4]))

二面

1.深挖项目,部分由项目引出的问题

  • Node.js应用崩溃后端侧处理
  • 白屏检测方案
  • pm2 cluster 多进程

会自动根据你的 CPU 核心数,启动多个 Node 服务进程,同时监听同一个端口,实现负载均衡。

  • 负载均衡相关

2.AI相关

  • AI上下文工具有哪些? spec等相关vibe coding行业实践了解吗?
  • vibe coding常见模式
  • AI工具/大模型选型依据 如何量化?

3.技术方案如何贴着当下的业务问题做?举例谈谈你的理解