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

刀带史VO挂经

🔗
匿名用户-KAZJF  2022-2-25 16:11:08 |倒序浏览

2022(1-3月) 码农类General 硕士 全职@doordash - 猎头 - Onsite 视频面试  | 🙁 Negative 😣 Hard | Fail | 在职跳槽

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

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

x
本帖最后由 匿名 于 2022-2-25 00:13 编辑

分享一个刀带史VO挂经

coding 1

蠡口吴刘凌
接下来问了如果改成是一个binary tree的话,如何找到a path sum to k,a path必须是从上到下的

system design
经典捐款系统 运行三天

coding 2
这个题估计是一个新题库题,面试官有完整的一套code,description,和testcases
具体variable的形式和名字不记得了,you get the idea
输入
1. List&l
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
diversity?




补充内容 (2022-02-27 03:59 +8:00):
Graph是undirected,可以跳过input 1,直接看input 3就可以了 有path 0->1的话就有path 1->0 time cost也是一样的

评分

参与人数 2大米 +9 收起 理由
匿名用户-XOSI7 + 8
Andyppp + 1 给你点个赞!

查看全部评分


上一篇:巨硬Codility电面不做题挂经
下一篇:日抛灵挂经+时间线
地里匿名用户
推荐
匿名用户-XJ45V  2022-3-7 06:49:54
写了一下第二题, 请大家看看有没有什么问题多多指教,time complexity我自己也搞不清楚 感觉是O(N^2)?
并且说一下 第一个条件canGoTo确实没有用上 因为假设timecost和points都必须给全了info
  1. import java.util.*;

  2. public class HighestPointsUnderTimeLimit {

  3.     public static int highestPoint;
  4.     public static int limit;
  5.     public static int getHighestPoint(List<List<Integer>> canGoTo, int[] points, int[][] timeCost, int timeLimit){
  6.         highestPoint = 0;
  7.         limit = timeLimit;
  8.         Map<Integer, Map<Integer, int[]>> srcToDestPointsCost = new HashMap<>();

  9.         for(int i = 0; i < timeCost.length; i++){
  10.             int src = timeCost[i][0];
  11.             int dest = timeCost[i][1];
  12.             int cost = timeCost[i][2];
  13.             int srcPoint = points[src];
  14.             int destPoint = points[dest];
  15.             int[] srcToDest = new int[]{destPoint, cost};
  16.             int[] destToSrc = new int[]{srcPoint, cost};
  17.             srcToDestPointsCost.computeIfAbsent(src, v -> new HashMap<>()).putIfAbsent(dest, srcToDest);
  18.             srcToDestPointsCost.computeIfAbsent(dest, v -> new HashMap<>()).putIfAbsent(src, destToSrc);
  19.         }
  20.         LinkedList<Integer> currPath = new LinkedList<>();
  21.         currPath.add(0);
  22.         dfs(srcToDestPointsCost, 0, points[0], 0, true, currPath);

  23.         return highestPoint;
  24.     }

  25.     private static void dfs(Map<Integer, Map<Integer, int[]>> srcToDestPointsCost, int start, int currPoints, int currTime, boolean isStart, LinkedList<Integer> currPath){
  26.         if((start == 0 && !isStart && currTime <= limit)){
  27.             System.out.println(Arrays.toString(currPath.toArray()));
  28.             highestPoint = Math.max(highestPoint, currPoints);
  29.             return;
  30.         } else if(currTime > limit){
  31.             return;
  32.         }

  33.         if(start == 0){
  34.             isStart = false;
  35.         }

  36.         Map<Integer, int[]> nextStops = srcToDestPointsCost.get(start);
  37.         for(Integer nextStart : nextStops.keySet()){
  38.             int[] info = nextStops.get(nextStart);
  39.             int newPoints = currPoints + info[0];
  40.             int newTime = currTime + info[1];
  41.             currPath.add(nextStart);
  42.             dfs(srcToDestPointsCost, nextStart, newPoints, newTime, isStart, currPath);
  43.             currPath.remove(nextStart);
  44.         }

  45.     }

  46.     public static void main(String args[]) {
  47.         List<List<Integer>> canGoTo = new ArrayList<>();
  48.         Integer[] l1 = new Integer[]{1, 2, 3};
  49.         Integer[] l2 = new Integer[]{3};
  50.         canGoTo.add(Arrays.asList(l1));
  51.         canGoTo.add(Arrays.asList(l2));

  52.         int[] points = new int[]{5, 10, 3, 20};
  53.         int[][] timeCost = new int[][]{{0, 1, 10}, {0, 2, 4}, {0, 3, 60}, {1, 3, 40}};
  54.         int timeLimit = 90;

  55.         System.out.println(getHighestPoint(canGoTo, points, timeCost, timeLimit));
  56.     }
  57. }
复制代码
回复

使用道具 举报

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

使用道具 举报

🔗
csmyhappy 2022-2-27 03:29:23 | 只看该作者
全局:
请问coding2这个题目 如果0可以到1 但是list中没有显示1可以到达0, 是否表示这个是directed graph 不能有0->1->0这条通路? 比较像力扣漆吧漆?
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-KAZJF  2022-2-27 03:59:51
csmyhappy 发表于 2022-2-26 11:29
请问coding2这个题目 如果0可以到1 但是list中没有显示1可以到达0, 是否表示这个是directed graph 不能有0 ...

graph 是undirected 第一个条件其实有点redundant
回复

使用道具 举报

🔗
csmyhappy 2022-2-27 07:33:21 | 只看该作者
全局:
匿名者 发表于 2022-2-26 11:59
graph 是undirected 第一个条件其实有点redundant

这题好难啊 绝望
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-KAZJF  2022-2-27 08:34:25

这个题应该就是try everything
回复

使用道具 举报

🔗
csmyhappy 2022-2-27 09:41:32 | 只看该作者
全局:
匿名者 发表于 2022-2-26 16:34
这个题应该就是try everything

是的 感觉DFS能做  Dijsktra做不了
回复

使用道具 举报

🔗
chipmunks123 2022-2-27 12:23:02 | 只看该作者
全局:
第二题和airbnb的滑雪题很像
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XJ45V  2022-3-5 05:14:29
Donation SD 能说的更具体点吗?好多人都提到过 但是没有具体描述 多谢了!
回复

使用道具 举报

全局:
csmyhappy 发表于 2022-02-26 17:41:32
是的 感觉DFS能做  Dijsktra做不了
怎么try everything? DFS 的同时看看时间够不够,而且看看能不能到起点?
回复

使用道具 举报

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

本版积分规则

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