📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

导大师 店面

🔗
匿名用户-WSCQB  2021-9-18 03:01:12 |倒序浏览

2021(7-9月) 码农类General 硕士 全职@doordash - 实习ReturnOffer - 技术电面  | 🙁 Negative 😣 Hard | WaitList | 在职跳槽

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

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

x
本帖最后由 匿名 于 2021-9-17 12:03 编辑

店面 华人
和LC   散而就 类似但是 求的是相
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
法 请share 思路

如果对您后面面试有帮助  求赐米
  1.   static int[][] d4 = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  2.   static int m, n;
  3.   public static int longestPathWithSameValue(int[][] A) {
  4.     int max = 0;
  5.     m = A.length;
  6.     n = A[0].length;
  7.     for (int i = 0; i < m; i++) {
  8.       for (int j = 0; j < n; j++) {
  9.         boolean[][] vis = new boolean[A.length][A[0].length];
  10.         max = Math.max(max, f(A, vis, i, j, A[i][j]));
  11.       }
  12.     }
  13.     return max;
  14.   }

  15.   /*
  16.   Note "You may not move diagonally or move outside the boundary (i.e., wrap-around is not
  17.   allowed)."
  18.      so it is not sum += f(A, vis, r, c, v);
  19.    */
  20.   private static int f(int[][] A, boolean[][] vis, int i, int j, int v) {
  21.     vis[i][j] = true;
  22.     int max = 1;
  23.     for (int[] d : d4) {
  24.       int r = i + d[0], c = j + d[1];
  25.       if (r >= 0 && c >= 0 && r < m && c < n && !vis[r][c] && A[r][c] == v)
  26.         max = Math.max(max, 1 + f(A, vis, r, c, v));
  27.     }
  28.     vis[i][j] = false;
  29.     return max;
  30.   }

  31.   // ==========================================================================
  32.   public static void main(String[] args) {
  33.     int[][] matrix =
  34.         (new int[][] {
  35.           {7, 9, 6},
  36.           {9, 9, 9},
  37.           {2, 9, 1}
  38.         });
  39.     System.out.println(longestPathWithSameValue(matrix) == 3);

  40.     matrix =
  41.         new int[][] {
  42.           {1, 1, 1, 2, 4},
  43.           {5, 1, 5, 3, 1},
  44.           {3, 4, 2, 1, 1}
  45.         };
  46.     System.out.println(longestPathWithSameValue(matrix) == 3);

  47.     matrix =
  48.         new int[][] {
  49.           {9, 9, 9, 9, 9, 9, 9},
  50.           {9, 9, 8, 9, 9, 9, 9},
  51.           {9, 9, 9, 12, 9, 9, 9},
  52.           {9, 9, 9, 12, 9, 9, 9},
  53.           {9, 9, 9, 12, 9, 9, 9},
  54.           {9, 9, 9, 12, 9, 9, 9}
  55.         }; // 37
  56.     System.out.println(longestPathWithSameValue(matrix) == 37);

  57.     matrix =
  58.         new int[][] {
  59.           {1, 3, 1, 1},
  60.           {0, 0, 5, 1},
  61.           {0, 0, 5, 5}
  62.         };
  63.     System.out.println(longestPathWithSameValue(matrix) == 4);

  64.     matrix =
  65.         new int[][] {
  66.           {1, 3, 1, 1},
  67.           {5, 5, 5, 1},
  68.           {5, 5, 5, 5}
  69.         };
  70.     System.out.println(longestPathWithSameValue(matrix) == 7);

  71.     matrix =
  72.         new int[][] {
  73.           {1, 1, 1, 3, 2},
  74.           {2, 1, 1, 4, 2},
  75.           {3, 3, 1, 1, 1},
  76.           {4, 4, 4, 3, 4}
  77.         };
  78.     System.out.println(longestPathWithSameValue(matrix) == 7);
  79.   }
复制代码

评分

参与人数 4大米 +9 收起 理由
ruoyi.rrr + 6 很有用的信息!
玉影 + 1 很有用的信息!
ginawang829 + 1 很有用的信息!
Sooners + 1 给你点个赞!

查看全部评分


上一篇:Tiktok两次电面被放鸽子
下一篇:CITADEL OA Bank
地里匿名用户
🔗
匿名用户-W371F  2021-9-26 05:10:34
无边界
好家伙这怎么解
请问lz最后过了吗
回复

使用道具 举报

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

本版积分规则

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