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

Bloomberg phone interview

全局:

2015(10-12月) 码农类General 硕士 全职@bloomberg - 内推 - 技术电面  | | Other | 应届毕业生

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

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

x
1. longest increasing subaray
2. find the max sum on the tree. contra
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
ith dynamic data rather than static data.

上一篇:10/19 新鲜面经,常规题
下一篇:问下找前端或者ios的面试,算法题都是用什么语言呢
推荐
 楼主| lianlu 2015-10-21 11:22:56 | 只看该作者
全局:
aiweiwei 发表于 2015-10-21 09:06
ok
get it, 终于想出来,感觉bottom up好做,类似强盗抢劫vilage,不能抢劫相邻的房子那道题目

这样可以嘛?
  1.         static int getSum(Tree t)
  2.         {
  3.             if (t == null) return 0;
  4.             return Math.max(helper(t), getSum(t.left) + getSum(t.right));
  5.         }

  6.         private static int helper(Tree root) // the max sum must include the root node
  7.         {   
  8.             if (root == null) return 0;
  9.             int leftleft = (root.left != null ) ? getSum(root.left.left) : 0;
  10.             int leftright = (root.left != null ) ? getSum(root.left.right) : 0;
  11.             int rightleft = (root.right != null ) ? getSum(root.right.left) : 0;
  12.             int rightright = (root.right != null ) ? getSum(root.right.right) : 0;   
  13.             
  14.             return root.nodeVal + leftleft + leftright + rightleft + rightright;
  15.         }
复制代码
回复

使用道具 举报

🔗
pixel 2015-10-20 04:52:58 | 只看该作者
全局:
Thank for sharing.
Not quite understand problem 2.
1. max sum of what? all nodes in the tree? nodes in the path from root to leaf?
2. is possible that the value of node is negative?
回复

使用道具 举报

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

使用道具 举报

🔗
royal_916 2015-10-21 04:06:04 | 只看该作者
全局:
第二题还是没太懂啊楼主  是类似于level order traversal的意思?
回复

使用道具 举报

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

使用道具 举报

🔗
aiweiwei 2015-10-21 08:19:39 | 只看该作者
全局:
楼主,第二题没思路,请问楼主是什么思路作的呀
回复

使用道具 举报

🔗
aiweiwei 2015-10-21 08:21:20 | 只看该作者
全局:
不是BST,就是一般的tree,也不一定full对吧,可以是各种形状
回复

使用道具 举报

🔗
aiweiwei 2015-10-21 09:06:58 | 只看该作者
全局:
ok
get it, 终于想出来,感觉bottom up好做,类似强盗抢劫vilage,不能抢劫相邻的房子那道题目
回复

使用道具 举报

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

本版积分规则

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