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

亚麻电面

全局:

2017(4-6月) 码农类General 本科 全职@amazon - 猎头 - 技术电面  | | Other | 在职跳槽

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

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

x
三哥面试官, 晚了三分钟 。
先介绍了一下他自己, 然后让我自我介绍。
又问我两个行为问题,
如果和你老板意见不一样怎么办?
工作中做过什么在你职责之外的事?
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
>
结果过了两天也没消息 , 可能没戏了。





上一篇:Yahoo! 会默拒吗?
下一篇:跪求Datavisor技术电面面经

本帖被以下淘专辑推荐:

  • · Amazon|主题: 131, 订阅: 68
🔗
lby8833 2017-4-28 12:50:02 | 只看该作者
全局:
别着急,有时候recruiter会回的慢一些。
回复

使用道具 举报

🔗
key91 2017-4-28 18:11:16 | 只看该作者
全局:
这题要放在tree里做。
回复

使用道具 举报

全局:
我想大概两种思路吧,
一个是build tree(graph), build完以后做一次dfs
另一个思路类似union find, 其实就是反向的tree

有个异常处理是要发现环, 如果有环就要抛出异常了
回复

使用道具 举报

🔗
qc999 2017-5-18 12:51:51 | 只看该作者
全局:
  1. package algorithm.Tree;

  2. import java.util.ArrayList;
  3. import java.util.LinkedList;
  4. import java.util.List;
  5. import java.util.Queue;
  6. public class NumberOfSubtreeNode {

  7.     public static void main(String[] argv){
  8.         String[][] strings={{"x","y"},{"y","z"},{"z","a"},{"y","b"}};
  9.         Node root=initial(strings);
  10.         System.out.print(root);
  11.     }


  12.     public static class Node{
  13.         public String name;
  14.         public List<Node> children;
  15.         public Node parent;
  16.         public int num;

  17.         public Node(String name){
  18.             this.name=name;
  19.             num=0;
  20.             parent=null;
  21.             children=new ArrayList<>();
  22.         }
  23.     }

  24.     public static Node initial(String[][] pairs){
  25.         if(pairs==null){
  26.             return null;
  27.         }
  28.         Node root=new Node(pairs[0][0]);

  29.         Node second=new Node(pairs[0][1]);

  30.         root.children.add(second);
  31.         second.parent=root;
  32.         root.num++;

  33.         for(int i=1;i<pairs.length;i++){
  34.             addNote(pairs[i],root);
  35.         }

  36.         return root;
  37.     }

  38.     public static void addNote(String[] pair,Node root){
  39.         String boss=pair[0];
  40.         String employee=pair[1];

  41.         Queue<Node> queue=new LinkedList<>();
  42.         queue.add(root);

  43.         while(!queue.isEmpty()){
  44.             Node node=queue.poll();
  45.             for(Node child:node.children){
  46.                 if(child.name.equals(boss)){
  47.                     Node newNode=new Node(employee);
  48.                     newNode.parent=child;
  49.                     child.children.add(newNode);
  50.                     Node parent=child;
  51.                     while(parent!=null){
  52.                         parent.num++;
  53.                         parent=parent.parent;
  54.                     }
  55.                     return;
  56.                 }
  57.                 queue.add(child);
  58.             }
  59.         }
  60.     }
  61. }
复制代码

keep a parent node, if find, all parent num add 1
回复

使用道具 举报

🔗
qc999 2017-5-18 13:01:02 | 只看该作者
全局:
  1.   public static void main(String[] argv){
  2.         String[][] strings={{"x","y"},{"y","z"},{"z","a"},{"y","b"}};
  3.         Map<String,Integer> result=initial(strings);
  4.         System.out.print(result);
  5.     }


  6.     public static class Node{
  7.         public String name;
  8.         public List<Node> children;
  9.         public Node parent;

  10.         public Node(String name){
  11.             this.name=name;
  12.             parent=null;
  13.             children=new ArrayList<>();
  14.         }
  15.     }

  16.     public static Map<String,Integer> initial(String[][] pairs){
  17.         Map<String,Integer> result=new HashMap<>();

  18.         if(pairs==null){
  19.             return null;
  20.         }
  21.         Node root=new Node(pairs[0][0]);

  22.         Node second=new Node(pairs[0][1]);

  23.         root.children.add(second);
  24.         second.parent=root;
  25.         result.put(root.name,1);
  26.         result.put(second.name,0);

  27.         for(int i=1;i<pairs.length;i++){
  28.             addNote(pairs[i],root,result);
  29.         }

  30.         return result;
  31.     }

  32.     public static void addNote(String[] pair,Node root,Map<String,Integer> result){
  33.         String boss=pair[0];
  34.         String employee=pair[1];

  35.         Queue<Node> queue=new LinkedList<>();
  36.         queue.add(root);

  37.         while(!queue.isEmpty()){
  38.             Node node=queue.poll();
  39.             for(Node child:node.children){
  40.                 if(child.name.equals(boss)){
  41.                     Node newNode=new Node(employee);
  42.                     result.put(employee,0);
  43.                     newNode.parent=child;
  44.                     child.children.add(newNode);
  45.                     Node parent=child;
  46.                     while(parent!=null){
  47.                         result.put(parent.name,result.get(parent.name)+1);
  48.                         parent=parent.parent;
  49.                     }
  50.                     return;
  51.                 }
  52.                 queue.add(child);
  53.             }
  54.         }
  55.     }
复制代码

use a map to record result
回复

使用道具 举报

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

本版积分规则

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