123
返回列表 发新帖
楼主: xxzjane
跳转到指定楼层
上一主题 下一主题
收起左侧

OpenAI 店面

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

使用道具 举报

🔗
cjl2 2024-1-22 16:08:55 | 只看该作者
全局:
本帖最后由 cjl2 于 2024-1-22 03:13 编辑

LZ, 麻烦一下, Interface 没有 set_cell("C", A+B) 这种方法吗?Cell addition? Cell subtraction?
回复

使用道具 举报

🔗
cuiyi 2024-1-23 04:01:20 | 只看该作者
全局:
xxzjane 发表于 2023-12-7 22:38
顺便求VO面经,或者加群,欢迎私信

楼主,求VO面经和群
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-X29KM  2024-1-31 07:57:13
感谢楼主分享,是店面一个小时内问两个题: 系统设计题+ coding题吗?
回复

使用道具 举报

🔗
jeremy_sea 2024-2-29 08:13:13 | 只看该作者
全局:
按照我的理解写了一遍, 感觉用DFS写会简单很多,不知道为啥需要用BFS?
  1. from typing import Dict, Set, Optional

  2. cell_dict: Dict[str, 'Cell'] = {}


  3. class Cell:
  4.     def __init__(self, value=None, child1=None, child2=None):
  5.         self.value = value
  6.         if value:
  7.             assert child1 == child2 is None
  8.         if child1 or child2:
  9.             assert value is None
  10.         self.child1 = child1
  11.         self.child2 = child2
  12.         self.parents: Set['Cell'] = set()

  13.     def get_value(self) -> int:
  14.         if self.value:
  15.             return self.value
  16.         if self.child1 not in cell_dict or self.child2 not in cell_dict:
  17.             raise ValueError(f"fail to find children c1: {self.child1} c2: {self.child2}")
  18.         v = cell_dict[self.child1].get_value() + cell_dict[self.child2].get_value()
  19.         self.value = v
  20.         return v

  21.     def set_parent(self, parent: 'Cell', visited: Optional[Set] = None):
  22.         if not visited:
  23.             visited = set()
  24.         if parent in visited:
  25.             raise ValueError("Circular dependency detected")
  26.         visited.add(parent)
  27.         self.parents.add(parent)
  28.         if self.child1 and self.child2:
  29.             cell_dict[self.child1].set_parent(self, visited)
  30.             cell_dict[self.child2].set_parent(self, visited)

  31.     def invalidate(self):
  32.         self.value = None
  33.         for parent in self.parents:
  34.             parent.invalidate()


  35. class SpreadSheet:
  36.     def get_cell_value(self, key: str):
  37.         return cell_dict[key].get_value()

  38.     def set_cell(self, key: str, cell: Cell):
  39.         if key in cell_dict:
  40.             cell_dict[key].invalidate()
  41.         cell_dict[key] = cell
  42.         if cell.child1 and cell.child2:
  43.             cell_dict[cell.child1].set_parent(cell)
  44.             cell_dict[cell.child2].set_parent(cell)


  45. spreadsheet = SpreadSheet()
  46. spreadsheet.set_cell("A", Cell(6))
  47. spreadsheet.set_cell("B", Cell(7))
  48. spreadsheet.set_cell("C", Cell(value=None, child1="A", child2="B"))
  49. assert spreadsheet.get_cell_value("C") == 13
  50. spreadsheet.set_cell("A", Cell(5))
  51. assert spreadsheet.get_cell_value("C") == 12

  52. spreadsheet.set_cell("D", Cell(10))
  53. spreadsheet.set_cell("E", Cell(15))
  54. spreadsheet.set_cell("F", Cell(value=None, child1="D", child2="E"))
  55. assert spreadsheet.get_cell_value("F") == 25, "Incorrect value for cell F"
  56. spreadsheet.set_cell("D", Cell(20))
  57. assert spreadsheet.get_cell_value("F") == 35, "Incorrect value for cell F after updating value of D"
  58. # Test 2: Test circular dependency detection
  59. try:
  60.     spreadsheet.set_cell("D", Cell(value=None, child1="F", child2="E"))
  61. except ValueError as e:
  62.     assert str(e) == "Circular dependency detected"
  63. else:
  64.     raise AssertionError("Circular dependency not detected as expected")



复制代码
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XJQIZ  2024-3-28 02:18:31
Hi 楼主,想问下你面openAI有遇到过iterator那道题吗?求面经 跪谢
回复

使用道具 举报

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

本版积分规则

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