📸我在 TikTok 面试写代码,被点赞了!|附两个原题+思路🔥-抖音 -VO support -定制化面试咨询

上个月刚刚面完 TikTok 的一轮远程技术面,想和大家分享下真实流程、面试氛围,以及——最重要的——两个原题和我的解法思路

🎥 面试开场:轻松但不敷衍

面试官是 TikTok 广告组的前端工程师,开场就很友好,先聊了下他在 Search Ads 团队做的项目,比如帮助广告主投放关键词广告,听上去还挺酷。他说:

“我是 TikTok 的前端工程师,已经在这里工作两年多了,最近在做搜索广告系统,比如帮助像 Nike 这样的客户设置关键字(如 '运动鞋'、'时尚')来匹配用户搜索词,让广告出现在 TikTok 上。”

然后他问了我过往经历,我简单介绍了自己在 Tesla 和 AWS 的实习:在 AWS 做的是基于 Typescript 和 AWS 构建的自动化数据平台,在 Tesla 则是做了一个防止磁性杂物影响方向盘的机械设计项目。他听得很认真,还追问了细节,最后表示:“那我们就开始做题啦,轻松点,没必要太紧张。”


🧠 第一题:Token 的生命周期管理(系统设计思维 + HashMap 操作)

题目原文:

There are authentication tokens that expire after a system-wide "expiryLimit". You will receive a list of commands sorted by time T:

  • [0, token_id, T]: create a token with id token_id at time T, which expires at T + expiryLimit.
  • [1, token_id, T]: reset token_id if it exists and hasn't expired, new expiry becomes T + expiryLimit.

Once a token expires, it cannot be reused or reset.

Return the number of active tokens at the latest time T in all commands.

💡 思路:

  • 用一个 dict 存储 token_id → 过期时间
  • 遍历所有命令,分类处理
    • 如果是创建指令,直接加进去
    • 如果是重置指令,先判断该 token 是否还活着,再更新它的过期时间
  • 最后,取最大的 T,看看每个 token 的过期时间是否还大于这个时间,统计数量

🧪 示例:

expiryLimit = 4
commands = [[0, 1, 1], [0, 2, 2], [1, 1, 5], [1, 2, 7]]
# 输出应该是 1,因为只有 token_id=1 在 T=7 时还活着

✅ 实现亮点:

  • 和面试官确认了逻辑后,我很快敲出了代码
  • 用 dict 存储过期时间,O(n) 时间复杂度搞定
  • 面试官问了下时间空间复杂度,我答:都是 O(n)

📷 第二题:谁能被镜头拍到?(从右往左单调栈思维)

题目原文:

There are n people in a line filming a TikTok. You are given an integer array heights of size n that represents the heights of the people in the line.

The camera is to the right of the people. A person can be seen in the recording if the person can see the camera without obstructions.

Formally, a person can be seen if all the people to their right have a smaller height.

Return a list of indices (0-indexed) of people that will be seen by the camera, sorted in increasing order.

举例:

heights = [4, 2, 3, 1]
# 输出 [0, 2, 3]
# 因为 1 肯定能看到,3 比 1 高也能看到,而 2 被 3 挡住,4 是最高的当然能看到

💡 思路:

  • 从右往左遍历数组
  • 维护一个当前最大的身高 max_height
  • 如果当前身高比 max_height 高,说明可以看到镜头,记录下索引
  • 最后结果反转一下,升序返回

✅ 实现细节:

  • 面试官也认可我这套逻辑,代码也一遍写完测试全过
  • 空间和时间复杂度都为 O(n)

💬 面试氛围 & 问答环节

写完代码后,面试官还留了不少时间让我问问题。

问了他在 TikTok 的工作流程,他详细讲了:

  • 前端开发从拿到需求文档 + Figma 图开始
  • 和产品经理、设计师对齐细节后自己写设计文档
  • 然后开始编码、联调、走 QA 环节、上线 A/B 测试

整体节奏比较自由,会议不多,能专注写代码。


✅ 总结:TikTok 面试感受 & 建议

评分:9/10,体验非常不错!

  • 💻 题目偏实用,重思路和表达,不只是硬刚代码
  • 🧑‍💼 面试官超级 chill,愿意互动,不摆架子
  • 🧠 技术讨论比背八股强,鼓励你讲出 trade-off 和优化思路
  • 📢 强烈建议提前刷几道系统设计思维的简单算法题,尤其是带状态管理的题目(如 token 管理)

📌 最后一句话送给准备面 TikTok 的同学:

不是每道题都要写成 LeetCode 竞赛解,但每道题你都要让面试官听懂你的思路 + 判断 + 抉择

祝大家都能 TikTok on offer ✨

经过csoahelp的面试辅助,候选人获取了良好的面试表现。如果您需要面试辅助面试代面服务,帮助您进入梦想中的大厂,请随时联系我

If you need more interview support or interview proxy practice, feel free to contact us. We offer comprehensive interview support services to help you successfully land a job at your dream company.

Leave a Reply

Your email address will not be published. Required fields are marked *