回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

微软四面凉经

全局:

2024(7-9月) 码农类General 硕士 全职@微软中国 - 网上海投 - 技术电面 视频面试  | Fail | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
本帖最后由 MeowMoew 于 2025-2-11 13:12 编辑

整理电脑翻到了半年前的面试,发上来求点米
SDE2岗位总共面了四轮,最后的结果是排序掉了,很遗憾没能抱上巨硬大腿-baidu 1point3acres

round1
Jump game 2, Greedy, 我用dfs写的,也给过了
followup:如何改进-空间换时间
  1. // https://leetcode.com/problems/jump-game-ii/
  2. // written during interview, can't promise the correctness, just for draft reference

  3. var minJump int = math.MaxInt

  4. // Additionally: use map to store calcuated value -> o(n) time complexity
  5. var indexToMinJump = make(map[int]int). 1point 3 acres

  6. func jump(nums []int) int {. Χ
  7.         // // special cases
  8.         // // 1. len = 0  2. len>=1, nums[0] == 0
  9.         // if len(nums) == 0 {
  10.         //         return 0
  11.         // }
  12.         search(nums, 0, 0)
  13.         return minJump
  14. }. 1point3acres.com

  15. func search(nums []int, index, count int) {
  16.         // index valid
  17.         if index < 0 || index >= len(nums) {
  18.                 return-baidu 1point3acres
  19.         }

  20.         // end condition.--
  21.         if index == len(nums)-1 {
  22.                 if count < minJump {
  23.                         minJump = count
  24.                 }. 1point 3 acres

  25.                 return
  26.         }

  27.         // jump. Χ
  28.         times := nums[index]

  29.         count++
  30.         for i := times; i >= 1; i-- {. 1point3acres
  31.                 search(nums, index+i, count)
  32.         }
  33. }
复制代码
round2 主要是聊项目,然后做了个简单的小题,问一共能想出多少种解法,最优解是什么
  1. // https://leetcode.com/problems/sort-colors
  2. // written during interview, can't promise the correctness, just for draft reference. Χ
  3. . .и
  4. // sort.google  и
  5. // [2,0,2,1,1,0] -> [0,0,1,1,2,2]
  6. // Method 1: classify through counting for each number, then appending

  7. func sortColors (nums []int){
  8.         numToCount := make([]int, 3)

  9.         for _, num := range nums {
  10.                 numToCount[num]++
  11.         }
  12. . 1point 3 acres
  13.         index := 0
  14.         for i, v := range numToCount {
  15.                 for j:=0; j<v; j++ {
  16.                         nums[index] = i
  17.                         index++
  18.                 }
  19.         }
  20. }

  21. // sort
  22. // [2,0,2,1,1,0] -> [0,0,1,1,2,2]
  23. // Method 2: two pointers, simulating quick sort, each time group one color, need to go through the process two times

  24. . 1point3acres.com
  25. func sortColors (nums []int){
  26.         // input validation ?. .и
  27.         if len(nums) < 2 {.
  28.                 return
  29.         }

  30.         // sort
  31.         left, right := 0, 1
  32.         pivot := nums[0]
  33.         . ----
  34.         //end condition: right - > end . Χ
  35.         for right < len(nums) {
  36.                 for nums[left]==pivot {
  37.                         left++
  38.                 }
  39.         
  40.                 for nums[right] != pivot {
  41.                         right++
  42.                 }. 1point3acres.com
  43.         . ----
  44.                 // switch. 1point 3 acres
  45.                 nums[left], nums[right] = nums[right], nums[left]. From 1point 3acres bbs
  46.         }

  47.         // iteration times control? 3->2
  48.         sortColors(nums[left:])
  49. }.

  50. // Method 3: iterate with two pointers, left:=0, right := len(nums), then iterate, if nums[i] == 0, switch with left, if nunms[i] == 2, switch with right
复制代码
您好!
本帖隐藏的内容需要积分高于 130 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 130 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

一周后收到thank u

评分

参与人数 3大米 +3 收起 理由
抬手就是扣 + 1 给你点个赞!
attt + 1 欢迎分享你知道的情况,会给更多积分奖励!
微信用户_a69bb13 + 1 给你点个赞!

查看全部评分


上一篇:阿里面经 - Base 杭州
下一篇:[求加米] 亚麻中国地区 SWE Intern OA + 时间线✅
推荐
 楼主| MeowMoew 2025-2-12 10:13:30 来自APP | 只看该作者
全局:
微信用户_a69bb13 发表于 2025-02-11 13:50:17
lz给你加米了!请问你这几轮的题都打出来了,那你知道为什么挂了吗?谢谢啦
跟帖子说的一样排序排掉了,前面有更优秀的接了offer
回复

使用道具 举报

地里匿名用户
推荐
匿名用户-SU6IV  2025-2-12 01:42:16
😂 2
软那么恶心 没什么好可惜的
回复

使用道具 举报

全局:
lz给你加米了!请问你这几轮的题都打出来了,那你知道为什么挂了吗?谢谢啦
回复

使用道具 举报

🔗
caiB 2025-2-28 10:06:06 来自APP | 只看该作者
全局:
这么难么? 最近面了两轮coding,两个面试官都当场反馈很好。
已经第三天了,还没有hr联系,也是国内。 ..
请问下楼主timeline
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表