Meta intern最近开放了 Software Engineer Intern,岗位有一点要求需要注意下 ‘This internship has a minimum twelve (12) week duration with 2025 start dates only’,必须是2025年毕业并且实习最少12周,最近也有不少小伙伴收到了Meta intern的面试,offer已经拿到了,start date February 3, 2025,现在分享下近期Meta intern的面试真题。
Meta Intern VO 1
Give two strings judge if one is a subsequence of another
Example:input: s = "abc", t = "ahbgdc"
output: true
Follow up question:
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s
Example:input: s = "abc", words = ["a", "bb", "acd", "ace"]
output: 2
解题思路
基本问题解法
双指针法:
- 用两个指针分别遍历两个字符串。
- 如果当前字符匹配,两个指针都移动;否则只移动主字符串指针。
- 如果子字符串的指针能遍历完,说明它是子序列。
时间复杂度:O(n),其中 n 是主字符串的长度。
Follow up解法
暴力法:
- 对
words中的每个字符串,用双指针法判断是否是s的子序列。 - 时间复杂度:O(m * n),其中 m 是
words的长度,n 是s的长度。
优化方法:
- 预处理主字符串
s:- 创建一个哈希表或数组
charIndex,存储主字符串中每个字符的出现位置。 - 利用二分查找快速找到匹配位置。
- 创建一个哈希表或数组
- 使用二分法快速定位:
- 对每个字符串中的字符,按照顺序在
s中用二分法找到下一个位置。 - 时间复杂度:O(n + m * k * log(n)),其中
k是words中字符串的平均长度。
- 对每个字符串中的字符,按照顺序在
Meta Intern VO 2
长度为 n 的数组 array,其中每个元素 x 满足 0 ≤ x ≤ n-1。找到数组中所有重复的元素。
Example
input: [3, 1, 2, 3, 0]
output: [3]
Follow up question
不能使用额外空间,不能递归调用或 func 调用
核心思想:原地修改数组,遍历数组中的每个元素,将元素放在正确的位置,将元素交换到正确的位置,如果该位置已被占用,则该元素是重复的
时间复杂度 O(n),空间复杂度 O(1)
Meta internship schedule
- 实习时间表(假设为12周):
- 第1-3周:入职培训
- 第5-6周:周期中期回顾
- 第10-11周:最终决定是否发放 offer(return offer 在此决定)
- 第11-12周:放松身心,享受乐趣。只有你在第1-10周的表现才会计入你的实习考核
告别面试烦恼,直取理想Offer!
经过我们的强力 VO 辅助 ,候选人通过这些面试题的解析和沟通,面试官不仅了解了候选人的编程能力,也看到了我在解决问题过程中清晰的思路和有效的沟通技巧。这些不仅有助于应对 Meta 的面试,同时也能提升我们解决实际编程问题的能力。祝大家面试顺利!