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

qualtrics 面筋

全局:

2019(10-12月) 码农类General 本科 实习@会计四大 - 网上海投 -   | | | 其他

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

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

x
Qualtrics 4 轮
1. 幺儿起
2. 岛数量加最大岛面积加最大有宝藏的岛面
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
reasing path. 起点和终点不定

评分

参与人数 3大米 +13 收起 理由
sccnju + 1 欢迎分享你知道的情况,会给更多积分奖励!
a610062656 + 2 欢迎分享你知道的情况,会给更多积分奖励!
匿名用户-IKFAS + 10

查看全部评分


上一篇:fb intern三轮timeline + 面试结果规律总结/推测
下一篇:audible电面面经
🔗
codeyy 2019-10-26 15:34:01 来自APP | 只看该作者
全局:
第三道题是一个图的遍历。dfs,bfs,unionfind都可解。那个半径指的是曼哈顿距离,对吧?

补充内容 (2019-10-26 07:38):
不同地雷的半径可能不一样。两个区间的重叠部分没必要再判断了。不知道有没有优化的算法
回复

使用道具 举报

🔗
codeyy 2019-10-26 15:36:22 来自APP | 只看该作者
全局:
第四道,好像力扣有原题。是一个拓扑排序,对吧
回复

使用道具 举报

🔗
a610062656 2019-11-5 22:33:38 | 只看该作者
全局:
codeyy 发表于 2019-10-26 15:34
第三道题是一个图的遍历。dfs,bfs,unionfind都可解。那个半径指的是曼哈顿距离,对吧?

补充内容 (2019- ...

Union Find不行,UnionFind你只能找到最大能炸多少个,但是你找不到应该第一个炸哪个
回复

使用道具 举报

🔗
学术大申 2019-11-10 12:18:16 | 只看该作者
全局:
lz 第三四题可以再多解释一下吗
回复

使用道具 举报

🔗
ccc123 2019-11-12 05:59:44 | 只看该作者
全局:
请问楼主有收到什么update吗?
回复

使用道具 举报

🔗
brian1868 2019-11-18 08:21:21 | 只看该作者
全局:
楼主最大宝藏能多讲一下吗?还有后两道题有没有比较好的思路?
回复

使用道具 举报

🔗
sccnju 2019-11-21 15:04:18 | 只看该作者
全局:
感觉楼主你考得蛮难的。

第四题有点像LeetCode 329
回复

使用道具 举报

🔗
oumizx 2020-7-1 14:52:07 | 只看该作者
全局:
写了一下最大宝藏的那题,在返回值里加了一个boolean判断当前岛有没有宝藏在传回来,因为java不允许一次return多个值,就改成return object。不知道有没有更加优雅的办法。
  1. public class MaxAreaWithTreasure {
  2.     int[][] DIRS = new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

  3.     class Island {
  4.         int num;
  5.         boolean hasTreature;

  6.         public Island(int num, boolean hasTreature) {
  7.             this.num = num;
  8.             this.hasTreature = hasTreature;
  9.         }
  10.     }

  11.     private int solution(int[][] grid) {
  12.         int res = 0;
  13.         for (int i = 0; i < grid.length; i++) {
  14.             for (int j = 0; j < grid[0].length; j++) {
  15.                 Island cur = helper(grid, i, j);
  16.                 if (cur.hasTreature) {
  17.                     res = Math.max(res, cur.num);
  18.                 }
  19.             }
  20.         }

  21.         return res;
  22.     }

  23.     private Island helper(int[][] grid, int row, int col) {
  24.         if (row < 0 || row >= grid.length || col < 0 || col >= grid[0].length || grid[row][col] == 0) {
  25.             return new Island(0, false);
  26.         }
  27.         boolean hasTreasure = false;
  28.         if (grid[row][col] == 2) {
  29.             hasTreasure = true;
  30.         }
  31.         grid[row][col] = 0;
  32.         int res = 1;

  33.         for (int[] dir : DIRS) {
  34.             int x = row + dir[0];
  35.             int y = col + dir[1];
  36.             Island curChild = helper(grid, x, y);
  37.             if (curChild.hasTreature) {
  38.                 hasTreasure = true;
  39.             }
  40.             res += curChild.num;
  41.         }

  42.         if (hasTreasure) {
  43.             return new Island(res, true);
  44.         } else {
  45.             return new Island(res, false);
  46.         }
  47.     }

  48.     public static void main(String[] args) {
  49.         MaxAreaWithTreasure solution = new MaxAreaWithTreasure();
  50.         int[][] grid = new int[][]{{2, 1, 0, 0}, {1, 0, 0, 1}, {0, 0, 1, 1}, {0, 0, 1, 1}};
  51.         System.out.println(solution.solution(grid));
  52.     }
  53. }
复制代码


回复

使用道具 举报

🔗
oumizx 2020-7-9 17:52:56 | 只看该作者
全局:
地雷那道题还挺麻烦的,想了一段时间才有头绪。直接用BFS不大方面,要同时考虑有地雷的格子和空格。我的解决办法是在BFS里用DFS, 在level order BFS里的每个level之后把用DFS得到的下一层的位置放到queue里。
  1. public int solution2(int[][] grid, int row, int col) {
  2.         Queue<int[]> q = new LinkedList<>();
  3.         q.add(new int[]{row, col});
  4.         Queue<int[]> bombsPos = new LinkedList<>();
  5.         boolean[][] visited = new boolean[grid.length][grid[0].length];
  6.         visited[row][col] = true;
  7.         bombsPos.add(new int[]{row, col});
  8.         int res = 1;
  9.         while (!bombsPos.isEmpty()) {
  10.             int size = bombsPos.size();
  11.             List<int[]> tempBombPos = new LinkedList<>();
  12.             for (int i = 0; i < size; i++) {
  13.                 int[] pos = bombsPos.remove();
  14.                 int r = pos[0];
  15.                 int c = pos[1];
  16.                 int range = grid[r][c];

  17.                 helper(tempBombPos, grid, visited, r, c, r, c, range);
  18.             }
  19.             res += tempBombPos.size();
  20.             for (int[] pos : tempBombPos) {
  21.                 bombsPos.add(pos);
  22.             }
  23.         }

  24.         return res;
  25.     }

  26.     private void helper(List<int[]> bombPos, int[][] grid, boolean[][] visited, int row, int col, int startRow, int startCol, int range) {
  27.         for (int[] dir : DIRS) {
  28.             int newRow = row + dir[0];
  29.             int newCol = col + dir[1];
  30.             if (newRow < 0 || newRow >= grid.length || newCol < 0 || newCol >= grid[0].length || visited[newRow][newCol] || (newRow - startRow) * (newRow - startRow) + (newCol - startCol) * (newCol - startCol) > range * range) continue;
  31.             visited[newRow][newCol] = true;
  32.             if (grid[newRow][newCol] != 0) {
  33.                 bombPos.add(new int[]{newRow, newCol});
  34.             }
  35.             helper(bombPos, grid, visited, newRow, newCol, startRow, startCol, range);
  36.         }

  37.     }

  38.     public static void main(String[] args) {
  39.         Bomb solution = new Bomb();
  40.         int[][] grid = new int[][]{{1, 2, 0, 0},{0, 0, 1, 0}, {0, 2, 0, 0}, {1, 0, 0, 1}};
  41.         System.out.println(solution.solution2(grid, 0, 0));
  42.     }
复制代码


回复

使用道具 举报

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

本版积分规则

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