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

[找工就业] 脸瘦家 DE L5 VO后的 Feedback

🔗
 楼主| 李浩泉 2020-8-2 06:17:31 | 只看该作者
全局:
Shubin_ren 发表于 2020-8-2 06:00
你的代码对于这个情况是错的. ----

'x y x' ['y','x'] 应该输出false
.1point3acres
谢谢,我已经意识到并且改正了。. Χ

  1. def words_order(text: str, words: list) -> bool:. .и
  2.     l = text.split()
  3.     dic = {}
  4.     for i,n in enumerate(l):
  5.         if n not in dic:  # 新加入的条件,这样字典法就是正确的了。
  6.             dic[n] = i
  7.     s = []
  8.     m = -1
  9.     for j in range(len(words)):
  10.         if words[j] in dic and dic[words[j]] > m :
  11.             s.append(words[j]). 1point3acres
  12.             m = dic[words[j]]. Χ
  13.     return s == words

  14. if __name__ == '__main__':
  15.     print("Example:").--
  16.     print(words_order('x x', ['x', 'x']))
  17.     print(words_order('x y x', ['y', 'x']))


  18.     assert words_order('x x', ['x', 'x']) == False
  19.     assert words_order('x y x', ['y', 'x']) == False
  20.     assert words_order('hi world im here', ['world', 'here']) == True
  21.     assert words_order('hi world im here', ['here', 'world']) == False ..
  22.     assert words_order('hi world im here', ['world']) == True
复制代码

. 1point 3acres
. 1point 3acres



本帖子中包含更多资源

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

x
回复

使用道具 举报

🔗
 楼主| 李浩泉 2020-8-2 06:19:32 | 只看该作者
全局:
忆桓公 发表于 2020-8-2 06:11
不对吧!我感觉是需要dict过一遍text的,只不过所有的词只记第一个index,因为题目中 ...
你的分析非常正确!!!
回复

使用道具 举报

🔗
柯基101 2020-8-2 06:24:35 | 只看该作者
全局:
李浩泉 发表于 2020-8-2 06:17
谢谢,我已经意识到并且改正了。

[mw_shl_code=python,true]def words_order(text: str, words: list) ...

你倒排序添加就好了啊,不用查重。。。
回复

使用道具 举报

🔗
gongchen 2020-8-2 06:33:31 | 只看该作者
全局:
忆桓公 发表于 2020-8-2 06:11. 1point3acres.com
不对吧!我感觉是需要dict过一遍text的,只不过所有的词只记第一个index,因为题目中 ...
一开始只看了时空复杂度没看答案对错
回复

使用道具 举报

🔗
niuhj 2020-8-2 06:38:59 | 只看该作者
全局:
这答案就是错的把,最基本的方法难道不是直接线性搜索吗。。。
回复

使用道具 举报

🔗
totolin 2020-8-2 06:39:53 | 只看该作者
全局:
根据题目要求应该得这样吧:
.
  1. def words_order(text, words):
  2.     word_list = text.split(' ')
  3.     wordset = set(words)
  4.     contain_list = [] ..
  5.     for word in word_list:
  6.         if word in wordset:
  7.             contain_list.append(word). 1point3acres
  8.             wordset.remove(word)
  9.     return contain_list == words
复制代码
. 1point3acres
楼主的code还有两点要注意:
1. for j in range(len(words)): 这情况下可以直接用 for word in words:, 能不用到处用words[j]让code更简明些
2. 除了i, j, m, n之类的常用的变量, 尽量不要用一个字母来作为命名. 比如 'l = text.split()' 可以变成 'word_tokens = text.split()',s, m, 也可以想些更有意义的名字,解释起来也容易。

评分

参与人数 3大米 +3 收起 理由
xwniu + 1 给你点个赞!
TensorFrozen + 1 赞一个
李浩泉 + 1 优秀!这个方法干净漂亮!

查看全部评分

回复

使用道具 举报

全局:
楼主我觉得你太妄自菲薄了,不过这也能看出fb的面试设计和hr确实很professional,能让candidate如此反省自己。我觉得楼主最大的遗憾是直接面l5,毕竟fb senior岗位本身的要求太高了。
回复

使用道具 举报

全局:
李浩泉 发表于 2020-08-01 12:45:31 ..
打完电话之后,我让HR给我一份written report,然后他就发了。我看官网上说,他们都会给feedback。

facebookrecruiting.com
HR太好了
回复

使用道具 举报

🔗
 楼主| 李浩泉 2020-8-2 07:02:15 | 只看该作者
全局:
totolin 发表于 2020-8-2 06:39
根据题目要求应该得这样吧:. 1point 3acres

[mw_shl_code=python,true]def words_order(text, word ...
优秀!这个方法干净漂亮!
回复

使用道具 举报

🔗
renee1 2020-8-3 04:33:35 | 只看该作者
全局:
谢谢楼主分享! 请问一下Big Data/AI 考的什么?
回复

使用道具 举报

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

本版积分规则

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