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

狗家10月底Onsite挂经

🔗
xil12008 2019-1-2 12:27:45 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

🔗
gggpps 2019-1-2 16:03:37 | 只看该作者
全局:
请问snack and ladder 那题是一个这个游戏的类吗
回复

使用道具 举报

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

使用道具 举报

🔗
yliu158 2019-1-6 03:03:52 | 只看该作者
全局:
给你点个赞!
回复

使用道具 举报

🔗
SDKmanager 2019-1-6 14:49:00 | 只看该作者
全局:
fengqitianlan 发表于 2019-1-2 04:38
只看上下左右4个方向

请问楼主,那是不是只要遍历一遍找到所有上下左右都是1的点mark出来,再最终遍历一遍变成0就可以了。感觉没考什么算法啊?是不是我理解有问题~
回复

使用道具 举报

🔗
youngliz283 2019-1-7 00:46:04 | 只看该作者
全局:
给你点个赞!
回复

使用道具 举报

全局:
SDKmanager 发表于 2019-1-6 14:49
请问楼主,那是不是只要遍历一遍找到所有上下左右都是1的点mark出来,再最终遍历一遍变成0就可以了。感觉 ...

我也觉得按照楼主的描述  就是你这样做就行
回复

使用道具 举报

🔗
lindali2010 2019-1-9 08:09:09 | 只看该作者
全局:
感谢lz分享,祝早日拿到offer。
第一题可以有parent point吗?还是只能由left,right?
回复

使用道具 举报

🔗
Ronald4545 2019-1-10 01:56:53 | 只看该作者
本楼:
全局:
what is LIS?

补充内容 (2019-1-10 02:45):
Ah, Longest increasing subsequence?
回复

使用道具 举报

🔗
Self_Learner 2019-1-11 14:46:42 | 只看该作者
全局:
第一题真狠,我写了下代码,应该是对的,大家可以看看
  1. class Solution {
  2.    
  3.     private Node {
  4.         int val;
  5.         Node left, right;
  6.         public Node (int val) {
  7.             this.val = val;
  8.         }
  9.     }
  10.    
  11.     public List<Integer> commonElem(Node a, Node b) {
  12.         List<Integer> res = new ArrayList<>();
  13.         if (a == null || b == null) return res;
  14.         
  15.         Node cur1 = a, cur2 = b;
  16.         
  17.         //move cur1 and cur2 to the smallest node.. and
  18.         //establish the the predecessor to successor link for inorder traverse...
  19.         findLeftMostNode(cur1);
  20.         findLeftMostNode(cur2);
  21.         
  22.         //compare the node one by one...
  23.         //if same, add value to the res.. and move both node to next;
  24.         //if cur1 < cur2.. only move cur1
  25.         // else move cur2...
  26.         while (cur1 != null && cur2 != null) {
  27.             if (cur1.val == cur2.val) {
  28.                 res.add(cur1.val);
  29.                 getNext(cur1);
  30.                 getNext(cur2);
  31.             } else if (cur1.val < cur2.val) {
  32.                 getNext(cur1);
  33.             } else {
  34.                 getNext(cur2);
  35.             }
  36.         }
  37.         
  38.         return res;
  39.     }
  40.    
  41.     private void getNext(TreeNode cur) {
  42.         if (cur.left == null) { cur = cur.right; }
  43.         TreeNode prev = cur.left;
  44.         while (prev.right != null && prev.right != cur) {
  45.             prev = prev.right;
  46.         }
  47.         if (prev.right == cur) {
  48.             prev.right = null;
  49.             cur = cur.right;
  50.         } else {
  51.             prev.right = cur;
  52.             cur = cur.left;
  53.         }
  54.     }
  55.    
  56.     private void findLeftMostNode(TreeNode cur) {
  57.         while (cur != null) {
  58.             if (cur.left == null) break;
  59.             TreeNode prev = cur.left;
  60.             while (prev.right != null) {
  61.                 prev = prev.right;
  62.             }
  63.             prev.right = cur;
  64.             cur = cur.left;
  65.         }
  66.     }
  67. }
复制代码
回复

使用道具 举报

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

本版积分规则

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