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

Tiktok 视频一面

🔗
匿名用户-VFXZV  2020-6-27 05:30:47 |倒序浏览

2020(4-6月) 码农类General 硕士 全职@bytedance - 猎头 - 视频面试  | | Fail | 在职跳槽

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

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

x
Tiktok MTV 广告组HR 勾搭,上海广告组国人小哥视频一面

前20分钟 自我介绍。项目经历,问得很细。

然后 B+ Tree相关。如何搜索,etc. 消息队列相关,如何保证order, 如何提升read/write 的并发量

一道很简单的算法,但
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
!!这坑爹的竞猜把大米坑完了!!!!!



补充内容 (2020-6-28 08:35):
把自己后来的两种实现都补充在楼下了,小伙伴们,求大米啊

评分

参与人数 13大米 +18 收起 理由
FrankBOKI + 1 给你点个赞!
erichuan2020 + 1 很有用的信息!
penny19960115 + 1 给你点个赞!
asyz13jinage + 1 很有用的信息!
oakwoods + 1 给你点个赞!

查看全部评分


上一篇:六月店面掛經
下一篇:twilio 电面和vo
地里匿名用户
推荐
匿名用户-VFXZV  2020-6-28 08:33:51

刚才那个是 返回值设void的。这个是返回值为int的
  1. static final int[][] direction = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

  2.     public static void island(int[][] A) {
  3.         if (A == null || A.length == 0 || A[0].length == 0) return;

  4.         for (int i = 0; i < A.length; i++) {
  5.             for (int j = 0; j < A[0].length; j++) {
  6.                 Set<String> visited = new HashSet<>();
  7.                 int ans = helper(A, i, j, visited);
  8.                 for (String str : visited) {
  9.                     String[] coordinates = str.split(" ");
  10.                     int x = Integer.valueOf(coordinates[0]);
  11.                     int y = Integer.valueOf(coordinates[1]);
  12.                     A[x][y] = ans;
  13.                 }
  14.             }
  15.         }
  16.     }

  17.     private static int helper(int[][] A, int x, int y, Set<String> visited) {

  18.         if (visited.contains(x + " " + y)) return 0;

  19.         if (A[x][y] != 1) return 0;
  20.         visited.add(x + " " + y);
  21.         int ans = 1;

  22.         for (int i = 0; i < 4; i++) {
  23.             int newX = direction[i][0] + x;
  24.             int newY = direction[i][1] + y;

  25.             // check boundary
  26.             if (newX >= A.length || newX < 0) continue;
  27.             if (newY >= A[0].length || newY < 0) continue;
  28.             ans += helper(A, newX, newY, visited);
  29.         }
  30.         return ans;
  31.     }
复制代码
[/i][/i]
回复

使用道具 举报

地里匿名用户
推荐
匿名用户-VFXZV  2020-6-28 08:22:33
  1. static final int[][] direction = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

  2.     public static void island(int[][] A) {
  3.         if (A == null || A.length == 0 || A[0].length == 0) return;

  4.         for (int i = 0; i < A.length; i++) {
  5.             for (int j = 0; j < A[0].length; j++) {
  6.                 Set<String> visited = new HashSet<>();
  7.                 int[] area = {0};
  8.                 helper(A, i, j, visited, area);
  9.                 for (String str : visited) {
  10.                     String[] coordinates = str.split(" ");
  11.                     int x = Integer.valueOf(coordinates[0]);
  12.                     int y = Integer.valueOf(coordinates[1]);
  13.                     A[x][y] = area[0];
  14.                 }
  15.             }
  16.         }
  17.     }

  18.     private static void helper(int[][] A, int x, int y, Set<String> visited, int[] area) {

  19.         if (visited.contains(x + " " + y)) return;

  20.         if (A[x][y] != 1) return;

  21.         area[0]++;
  22.         visited.add(x + " " + y);

  23.         for (int i = 0; i < 4; i++) {
  24.             int newX = direction[i][0] + x;
  25.             int newY = direction[i][1] + y;

  26.             // check boundary
  27.             if (newX >= A.length || newX < 0) continue;
  28.             if (newY >=A[0].length || newY < 0) continue;
  29.             helper(A, newX, newY, visited, area);
  30.         }
  31.     }
复制代码
[/i][/i]
回复

使用道具 举报

🔗
nomadlion 2020-6-27 12:41:27 | 只看该作者
全局:
dfs+uf可破

评分

参与人数 1大米 +1 收起 理由
小堆堆 + 1 赞一个!

查看全部评分

回复

使用道具 举报

全局:
Union Found 有点Over Kill了吧 只要把DFS 返回值设为int就好了呀
回复

使用道具 举报

🔗
nomadlion 2020-6-28 07:53:49 | 只看该作者
全局:
啤酒加盐 发表于 2020-6-27 13:09
Union Found 有点Over Kill了吧 只要把DFS 返回值设为int就好了呀

dfs返回值只能解决一个方向吧,如果右面和下面都有咋办?比如
1 1
1 0
回复

使用道具 举报

🔗
gongchen 2020-6-28 07:58:40 | 只看该作者
全局:
nomadlion 发表于 2020-6-28 07:53
dfs返回值只能解决一个方向吧,如果右面和下面都有咋办?比如
1 1
1 0

四个方向都dfs有啥问题么?
回复

使用道具 举报

🔗
nomadlion 2020-6-28 08:00:48 | 只看该作者
全局:
gongchen 发表于 2020-6-28 07:58
四个方向都dfs有啥问题么?

求code,up up up
回复

使用道具 举报

全局:
我跟你相反,算法题秒但是基础知识一塌糊涂……
回复

使用道具 举报

🔗
nomadlion 2020-6-28 08:15:12 | 只看该作者
全局:

对于
1,1
1,0
做完右面dfs
2,2
1,0
再做下面dfs
3,2
3,0
怎么把(0,1)的2变成3?
回复

使用道具 举报

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

本版积分规则

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