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

萝卜丝 karat面经

🔗
匿名用户-6A0SC  2023-4-25 12:16:18 |倒序浏览

2023(4-6月) 工程类 硕士 全职@roblox - 网上海投 - 技术电面 视频面试  | 😃 Positive 😐 Average | Other | 在职跳槽

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

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

x
最近都没karat 面经似乎他们换题了,地里看到的都没遇到第一题, input 是一个 studentID 和 course 的二维数组 类似 [["56", "course1"], ["41", "course2"], ["56", "course3"], ["48", "course2"], ["41", "course1"]] 要求output 是 每一对 pair和他们的共同course。 比如 {["56,41", "course1"], ["56,48", ""], ["48,41", "course2"]}, 即使没用共同课程也需要输出 我用map 套 set做的

第二题
You're developing a system for scheduling advising meetings with students in a Computer Science program. Each meeting should be scheduled when a student has completed 50% of their academic program.
Each course at our university has at most one prerequisite that must be taken first. No two courses share a prerequisite. There is only one pat
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
"Algorithms"],
]
Sample output 3:
"Data Structures"
All Test Cases:
halfway_course(pairs1) => "Data Structures"
halfway_course(pairs2) => "Foundations of Computer Science"
halfway_course(pairs3) => "Data Structures"
Complexity analysis variables:
n: number of pairs in the input
*/
时间不多没怎么想 用的map没写完但是讲了思路,可能有更好的方法。不知道有没有机会T T

求米求米求米!!!!

评分

参与人数 6大米 +21 收起 理由
bc2615 + 2 给你点个赞!
Ccqw12 + 1 给你点个赞!
eliblack + 1 给你点个赞!
harsk + 1 赞一个
bryanjhy + 15 给你点个赞!

查看全部评分


上一篇:Flexport Senior VO 已过 求捞
下一篇:TT电商
推荐
city 2023-5-23 07:49:30 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

🔗
eliblack 2023-5-11 11:54:38 | 只看该作者
全局:
第二题应该是topological sorting吧
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-GTGO7  2023-5-21 09:28:25
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

🔗
crzzz 2023-6-7 11:02:25 | 只看该作者
全局:
第二题是这个意思不
  1. Class Solution{
  2.         class Course {
  3.                 String name,
  4.                 Course child;
  5.         }
  6.         public String findMedianCourses(String[][] courses) {
  7.                 Map<String, Course> allCourse = new HashSet<>();
  8.                 Set<String> pendingCourse = new HashSet<>(); // courses that current have no parents
  9.                 for (String[] course: courses) {
  10.                         String childName = course[0];                //child course
  11.                         String parenName = course[1];        // prereq course

  12.                         boolean seenParent = allCourse.contains(parentCourseName);

  13.                         Course child = allCourse.getOrDefault(childName, new Course(childName, null));
  14.                         Course parent = allCourse.getOrDefault(parenName, new Course(parenName, null));
  15.                         parent.child = child;


  16.                         allCourse.put(childName, child);
  17.                         allCourse.put(parentName, parent);

  18.                         pendingCourse.remove(child); // might have child in pending, let's remove
  19.                         if (!seenParent) {
  20.                                 pendingCourse.add(second);
  21.                         }
  22.                 }

  23.                 String rootName = pendingCourse.iterator().next();
  24.                 Course ptr = allCourse.get(root);
  25.                 int stopIndex = (allCourse.size()-1)/2;

  26.                 for(int i = 1; i <= stopIndex; i++) {
  27.                         ptr = ptr.next;
  28.                 }
  29.                 return ptr.name;
  30.         }
  31. }
复制代码
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-6A0SC  2023-6-9 05:17:53
本楼:
蠡口 207
回复

使用道具 举报

全局:
第一题,如果可以assume课程数有限,比如1000个,可以用bitset,这样每个交集的计算都是常数级别的位计算。不过代价是需要多维护一个course->index以及index->course的map。
回复

使用道具 举报

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

本版积分规则

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