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

[面试经验] FB data scientist, analytics 电面

 
🔗
 楼主| onetwo 2017-12-1 11:48:24 | 只看该作者
全局:
Alice007 发表于 2017-11-23 00:49
嗯,fb面试就那么几个题目,然后不同变种,感觉了解好数据以及之间的逻辑是关键!另外地里的回帖功能需要 ...

. .и是的 基本就是join, union all这些。有时候一个表 有时候两个表,但是逻辑都是类似的,理解清楚就好。你写的第一个query我觉得应该是对的哈
回复

使用道具 举报

🔗
 楼主| onetwo 2017-12-1 11:52:51 | 只看该作者
全局:
amour0_0 发表于 2017-12-1 08:44
谢谢楼主,今天店面就是这个题目, 一模一样

不客气,能帮到大家就好。 我好奇第二题思路应该是什么样的?我平时不做产品,这个不是很清楚应该怎么答比较好。希望大家不吝指教,讨论讨论
回复

使用道具 举报

🔗
 楼主| onetwo 2017-12-1 11:58:34 | 只看该作者
全局:
Alice007 发表于 2017-11-23 00:54
第三个sql题目:
请lz/层主们帮忙看看对不对哈
.--
这个好像不太对,我的思路是,你用个MAX()去找每个user 给top partner发的信息数,同时SUM()得到每个user发的总信息数。然后再加一个outer query把这两列值SUM over all users 再相除就好了。
回复

使用道具 举报

🔗
Cwu22 2017-12-7 06:41:39 | 只看该作者
全局:
想请教第一题第二小问的distribution 可能是什么分布呀?
回复

使用道具 举报

🔗
jiangh52 2017-12-31 16:03:05 | 只看该作者
全局:
(非米DA)
1-2, 这种distribution大多数情况都是接近于指数分布的形状吧

2 会根据当期的目标和整体产品战略具体制定。
但你可以优先用第一问的数据来答啊。
可能的metrics比如说
用来利用网络的密度的(用第一问的数据)
- pair count的各qunatile的时间推移.--
- new pairs的产生数量的时间推移. ----
用来观测用户利用率的:
- msg_dau / (fb_+msg_dau)
用来观测用户数的:
- msg_uu / goal_uu
- msg_mau / msg_last_mau.google  и
用来观测产品的渗透度的. 1point3acres
- 利用时长的各quantile的时间推移
- 有利用的hour数的各quantile的时间推移

评分

参与人数 1大米 +20 收起 理由
匿名用户-BLX16 + 20

查看全部评分

回复

使用道具 举报

🔗
stonephoenix 2018-1-10 09:03:31 | 只看该作者
全局:
正在准备面试,所以把自己的答案写一下,有错的话请大家一定要指出来啊!多谢!
(2)写个query得到某一天用户发消息朋友数量的distribution,就是output出两列,X: number of unique contacts for each user; Y: number of user with this many contacts。问你觉得这个distribution会长什么样子
  1. select histo.cnt_contact as cnt_contact,
  2.   count(histo.userid) as cnt_users
  3. from
  4. (. Χ
  5.   select
  6.         tall.u1 as userid,
  7.     count(*) as cnt_contact-baidu 1point3acres
  8.   from . check 1point3acres for more.
  9.   (
  10.     select t1.u1 as u1, t1.u2 as u2
  11.     from contact t1
  12.     union all. Χ
  13.     select t2.u2 as u1, t2.u1 as u2
  14.     from contact t2
  15.   ) tall
  16.   group by tall.u1
  17. ) histo
  18. group by histo.cnt_contact
  19. order by count(histo.userid)
复制代码


3。 SUM(n_msg_with_top_partner)/SUM(all_messages_with_all_contacts),sum over all users.
  1. select
  2.         tmax.userid,
  3.         tmax.friendid,
  4.         pct = tmax.n_msg / sum(tmax.n_msg ) over( partition by tmax.userid)
  5. from
  6. (
  7.         select. Waral dи,
  8.                 userid = tcnt.userid,
  9.                 friendid = tcnt.freindid,. Χ
  10.                 n_msg = tcnt.n_msg,
  11.                 rnk = ROW_NUMBER() over (partition by tcnt.userid order by tcnt.cnt_contact desc)
  12.         from
  13.         (
  14.           select
  15.                 tall.u1 as userid,
  16.                 tall.u2 as freindid,
  17.                 tall.n_msg as n_msg. Waral dи,
  18.           from
  19.           (
  20.                 select t1.u1 as u1, t1.u2 as u2, t1.n_msg
  21.                 from contact t1
  22.                 union all
  23.                 select t2.u2 as u1, t2.u1 as u2, t2.n_msg
  24.                 from contact t2 . From 1point 3acres bbs
  25.           ) tall
  26.         ) tcnt. ----
  27. ) tmax
  28. group by tmax.userid. check 1point3acres for more.
  29. having tmax.rnk = 1
复制代码

评分

参与人数 1大米 +30 收起 理由
匿名用户-BLX16 + 30 很有用的信息!

查看全部评分

回复

使用道具 举报

🔗
stonephoenix 2018-1-10 09:16:38 | 只看该作者
全局:
stonephoenix 发表于 2018-1-10 09:03.
正在准备面试,所以把自己的答案写一下,有错的话请大家一定要指出来啊!多谢!. Χ
(2)写个query得到某一天 ...
.
第3 个having 用法不对。。。。感觉还是要再加一层。。。
回复

使用道具 举报

🔗
stonephoenix 2018-1-10 09:33:30 | 只看该作者
全局:
修改后的第3问
. 1point3acres.com
  1. drop table contact
  2. create table contact(
  3.         u1 int,
  4.         u2 int,
  5.         n_msg int ..
  6. )
  7. insert contact (u1, u2, n_msg) values
  8. (1,2, 1), (1,3, 2), (1, 4,6),
  9. (2,1, 3), (2,3, 2), (2,4, 5),
  10. (3,1, 2), (3,2, 3)


  11. select userid, friendid, n_msg, sum_msg, pct
  12. from ..
  13. (
  14.         select
  15.                 tmax.userid, . check 1point3acres for more.
  16.                 tmax.friendid,-baidu 1point3acres
  17.                 tmax.n_msg,. 1point 3 acres
  18.                 sum_msg = sum(tmax.n_msg ) over( partition by tmax.userid),
  19.                 pct = (tmax.n_msg + 0.0) / sum(tmax.n_msg ) over( partition by tmax.userid),.google  и
  20.                 tmax.rnk
  21.         from ..
  22.         (
  23.                 select
  24.                         userid = tcnt.userid,
  25.                         friendid = tcnt.freindid,
  26.                         n_msg = tcnt.n_msg,.1point3acres
  27.                         rnk = ROW_NUMBER() over (partition by tcnt.userid order by tcnt.n_msg desc)
  28.                 from
  29.                 (
  30.                   select
  31.                         tall.u1 as userid,
  32.                         tall.u2 as freindid,
  33.                         sum(tall.n_msg) as n_msg
  34.                   from
  35.                   (
  36.                         select t1.u1 as u1, t1.u2 as u2, t1.n_msg
  37.                         from contact t1
  38.                         union all
  39.                         select t2.u2 as u1, t2.u1 as u2, t2.n_msg
  40.                         from contact t2
  41.                   ) tall
  42.                   group by tall.u1, tall.u2. ----
  43.                 ) tcnt
  44.         ) tmax
  45. ) tt
  46. where tt.rnk = 1
复制代码


弄下来感觉挺啰嗦的。。。求大神指点
回复

使用道具 举报

🔗
sbdxxcjh 2018-1-26 13:17:44 | 只看该作者
全局:

where应该是作用在windows function之前的,所以第三问最后你用where限定rank = 1的话,上面的ratio好像都是1了。。
回复

使用道具 举报

🔗
linda.zhou 2018-1-30 05:36:55 | 只看该作者
全局:
SQL: select u1, count(distinct u2) from table group by 1

补充内容 (2018-1-30 05:39):. Waral dи,
本来想着换行结果直接发出来了也是醉了 在下面补充
回复

使用道具 举报

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

本版积分规则

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