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

脸书电面

全局:

2018(4-6月) 码农类General 硕士 全职@meta - 猎头 - 在线笔试  | | Other | 在职跳槽

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

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

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



题目不难,但是第一次做的话,parser substring有难度。

评分

参与人数 4大米 +25 收起 理由
FightOn + 10 这个题真的很复杂,电话面试就搞这个有点。.
Cap_13 + 5 原贴已加。
idatascience + 5 很有用的信息!
yongmat + 5 很有用的信息!

查看全部评分


上一篇:Trexquant跪经
下一篇:请问上周五有去过Providence Health & Service Onsite 的朋友吗
推荐
kevinxw 2018-4-28 14:25:50 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

推荐
 楼主| xmasry 2018-4-28 12:58:20 | 只看该作者
全局:
  1. public Node parse(String nodeStr) {
  2.                         if(nodeStr == null || nodeStr.isEmpty()) {
  3.                                 return null;
  4.                         }
  5.                        
  6.                         int l = nodeStr.indexOf("(");
  7.                         if(l < 0) {
  8.                                 return new Node(nodeStr);
  9.                         }
  10.                        
  11.                         Node root = new Node(nodeStr.substring(0, l));
  12.                         root.children = new LinkedList<Node>();
  13.                         String childStr = nodeStr.substring(l+1, nodeStr.lastIndexOf(")"));               
  14.                         while(!childStr.isEmpty()){
  15.                                 int lc = childStr.indexOf(",");                       
  16.                                 if(lc < 0 ) {
  17.                                         root.children.add(parse(childStr.trim()));
  18.                                         break;
  19.                                 }
  20.                                 int llc = childStr.indexOf("(");
  21.                                 if(llc<0 || lc < llc) { //substr : node_b,node_d()
  22.                                         root.children.add(parse(childStr.substring(0,lc).trim()));
  23.                                 }else { //substr:  node_c(node_d, node_e), node_b)
  24.                                         int rc = getEndOfFristNode(childStr, llc+1);
  25.                                         root.children.add(parse(childStr.substring(0,rc).trim()));
  26.                                         lc = rc;
  27.                                 }
  28.                                
  29.                                 childStr = childStr.substring(lc+1);
  30.                         }
  31.                        
  32.                         return root;
  33.                 }
  34.                
  35.                 private int getEndOfFristNode(String str, int start) {
  36.                         int res = start, i = start;
  37.                         int cnt = 1;
  38.                         while(i<str.length() && cnt>0) {
  39.                                 if(str.charAt(i)=='(') {
  40.                                         ++cnt;
  41.                                 }else if(str.charAt(i)==')') {
  42.                                         --cnt;
  43.                                 }
  44.                                 i++;
  45.                         }
  46.                         return i;
  47.                 }               
  48.                 // whether the trees represented by given string are the same, ignoring the
  49.                 public boolean isSameTree(String str1, String str2 ) {
  50.                         Node tree1 = parse(str1);
  51.                         Node tree2 = parse(str2);
  52.                         if(tree1 == null && tree2 == null) {
  53.                                 return true;
  54.                         }else if(tree1 == null || tree2 == null) {
  55.                                 return false;
  56.                         }
  57.                        
  58.                         return tree1.isSameIgnoreChildSort(tree2);
  59.                 }
复制代码
回复

使用道具 举报

推荐
kevinxw 2018-4-28 23:38:51 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

🔗
idatascience 2018-4-26 10:02:39 | 只看该作者
全局:
取括号最外面的作为root,然后parse string,生成parent:children list。对另一个string做同样的操作。然后用一个map check两个string node对应的关系
回复

使用道具 举报

🔗
idatascience 2018-4-26 10:03:20 | 只看该作者
全局:
请问楼主master在职跳槽,你现在的工作也是IT相关行业么?
回复

使用道具 举报

🔗
Fly365 2018-4-26 16:02:22 | 只看该作者
全局:
LZ有实现的代码吗?
回复

使用道具 举报

全局:
我4月19日下午电面,4月23日下午给我打电话说positive feedback让准备onsite
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

🔗
 楼主| xmasry 2018-4-27 01:22:42 | 只看该作者
全局:
数据结构自己设计
Node {
   String name;
   List<Node> children;
}
回复

使用道具 举报

🔗
dimi 2018-4-27 01:33:11 | 只看该作者
全局:
thanks for sharing. nice question atcually.
回复

使用道具 举报

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

本版积分规则

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