📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 2
跳转到指定楼层
上一主题 下一主题
收起左侧

Hubspot OA 面筋和准备材料

全局:

2025(4-6月) 码农类General 硕士 全职@hubspot - 网上海投 - 在线笔试  | 🙁 Negative 😣 Hard | Pass | 在职跳槽

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

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

x
本帖最后由 微信用户_ky8ei 于 2025-4-19 11:12 编辑

他们的OA是http call一个endpoint,返回数据,根据页面提供的逻辑写代码生成数据,在调用一
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
ort json

  1. import requests


  2. def check_permission(user_id, owner_id, permission_level, users_with_id_key):
  3.     if permission_level == "ALL":
  4.         return True
  5.     elif permission_level == "OWNED_OR_TEAM":
  6.         if user_id == owner_id:
  7.             return True
  8.         else:
  9.             user_teams = users_with_id_key[user_id]["teamIds"]
  10.             owner_teams = users_with_id_key[owner_id]["teamIds"]
  11.             if any([user_team in owner_teams for user_team in user_teams]):
  12.                 return True
  13.     elif permission_level == "OWNED_ONLY":
  14.         if user_id == owner_id:
  15.             return True

  16.     return False


  17. def process_data(data):
  18.     result = []
  19.     users_with_id_key = {item["userId"]: item for item in data["users"]}

  20.     for user in data["users"]:
  21.         user_id = user["userId"]
  22.         viewPermissionLevel = user["viewPermissionLevel"]
  23.         editPermissionLevel = user["editPermissionLevel"]
  24.         user_data_to_append = {
  25.             "userId": user["userId"],
  26.             "viewableDealIds": [],
  27.             "editableDealIds": []
  28.         }

  29.         for deal in data["deals"]:
  30.             deal_id = deal["dealId"]
  31.             owner_id = deal["ownerUserId"]
  32.             if check_permission(user_id, owner_id, viewPermissionLevel, users_with_id_key):
  33.                 user_data_to_append["viewableDealIds"].append(deal_id)
  34.             if check_permission(user_id, owner_id, editPermissionLevel, users_with_id_key):
  35.                 user_data_to_append["editableDealIds"].append(deal_id)
  36.         result.append(user_data_to_append)
  37.     return result


  38. def get_data(url):
  39.     response = requests.get(url)
  40.     return response.json()

  41. def send_data(url, data):
  42.     response = requests.post(url, json=data)
  43.     print(f"Response Status Code: {response.status_code}")
  44.     print(f"Response Status Text: {response.text}")


  45. if __name__ == '__main__':
  46.     raw_data = """
  47.     {
  48.         "users": [{
  49.             "userId": 1,
  50.             "teamIds": [5],
  51.             "viewPermissionLevel": "OWNED_OR_TEAM",
  52.             "editPermissionLevel": "OWNED_ONLY"
  53.         }, {
  54.             "userId": 2,
  55.             "teamIds": [5],
  56.             "viewPermissionLevel": "ALL",
  57.             "editPermissionLevel": "OWNED_ONLY"
  58.         }, {
  59.             "userId": 3,
  60.             "teamIds": [],
  61.             "viewPermissionLevel": "OWNED_OR_TEAM",
  62.             "editPermissionLevel": "ALL"
  63.         }],
  64.         "deals": [{
  65.             "dealId": 10,
  66.             "ownerUserId": 1
  67.         }, {
  68.             "dealId": 20,
  69.             "ownerUserId": 2
  70.         }, {
  71.             "dealId": 30,
  72.             "ownerUserId": 3
  73.         }]
  74.     }
  75.    
  76.     """

  77.     example_output = """
  78.     {
  79.         "results": [{
  80.             "userId": 1,
  81.             "viewableDealIds": [10, 20],
  82.             "editableDealIds": [10]
  83.         }, {
  84.             "userId": 2,
  85.             "viewableDealIds": [10, 20, 30],
  86.             "editableDealIds": [20]
  87.         }, {
  88.             "userId": 3,
  89.             "viewableDealIds": [10, 20, 30],
  90.             "editableDealIds": [10, 20, 30]
  91.         }]
  92.     }
  93.    
  94.     """

  95.     data = json.loads(raw_data)

  96.     result = process_data(data)

  97.     print(json.dumps(result, indent=4))
复制代码
二、电话峰值题
  1. <div>
  2. </div><div>"""
  3. <a href="https://leetcode.com/discuss/post/5833936/hubspot-interview-guidance-by-anonymous_-3xsp/" target="_blank">https://leetcode.com/discuss/pos...by-anonymous_-3xsp/</a>
  4. """

  5. import json
  6. from datetime import datetime, timedelta

  7. import requests


  8. def get_dates_between(start_timestamp, end_timestamp):
  9.     start_date = datetime.fromtimestamp(start_timestamp / 1000).date()
  10.     end_date = datetime.fromtimestamp((end_timestamp-1) / 1000).date()

  11.     current_date = start_date
  12.     dates = []

  13.     while current_date <= end_date:
  14.         dates.append(current_date.strftime('%Y-%m-%d'))
  15.         current_date += timedelta(days=1)
  16.     return dates


  17. def process_data(data):
  18.     data_by_customer_id_and_date = {}
  19.     for call in data:
  20.         customer_id = call["customerId"]
  21.         start_timestamp = call["startTimestamp"]
  22.         end_timestamp = call["endTimestamp"]
  23.         dates = get_dates_between(start_timestamp, end_timestamp)

  24.         if customer_id not in data_by_customer_id_and_date:
  25.             data_by_customer_id_and_date[customer_id] = {}
  26.         for date in dates:
  27.             if date not in data_by_customer_id_and_date[customer_id]:
  28.                 data_by_customer_id_and_date[customer_id][date] = []
  29.             data_by_customer_id_and_date[customer_id][date].append(call)
  30.     return data_by_customer_id_and_date

  31. def process_customer_for_a_day(call_in_a_day, date):
  32.     ts_for_the_day = int(datetime.strptime(date, '%Y-%m-%d').timestamp() * 1000)
  33.     sweep_lines = []
  34.     for call in call_in_a_day:
  35.         call_id = call["callId"]
  36.         start_ts = call["startTimestamp"]
  37.         end_ts = call["endTimestamp"]

  38.         sweep_lines.append([start_ts, 1, call_id])
  39.         sweep_lines.append([end_ts, -1, call_id])
  40.     sweep_lines_sorted = sorted(sweep_lines, key=lambda x: [x[0], x[1]])
  41.     print(sweep_lines_sorted)

  42.     result = {
  43.       "customerId": call_in_a_day[0]["customerId"],
  44.       "date": date,
  45.       "maxConcurrentCalls": 0,
  46.       "timestamp": ts_for_the_day,
  47.       "callIds": [
  48.       ]
  49.     }

  50.     concurrent_calls = set()
  51.     for d in sweep_lines_sorted:
  52.         ts = d[0]
  53.         start_or_end = d[1]
  54.         call_id = d[2]
  55.         if start_or_end > 0:
  56.             concurrent_calls.add(call_id)
  57.             if len(concurrent_calls) > result["maxConcurrentCalls"]:
  58.                 # find a new peak
  59.                 result["maxConcurrentCalls"] = len(concurrent_calls)
  60.                 result["callIds"] = list(concurrent_calls)
  61.                 if ts > ts_for_the_day:
  62.                     result["timestamp"] = ts
  63.         else:
  64.             concurrent_calls.remove(call_id)
  65.     return result



  66. def process_all_customer_for_all_day(data):
  67.     data_by_customer_id_and_date = process_data(data)
  68.     result = []
  69.     for customer_id in data_by_customer_id_and_date:
  70.         for date in data_by_customer_id_and_date[customer_id]:
  71.             result.append(process_customer_for_a_day(data_by_customer_id_and_date[customer_id][date], date))

  72.     return result


  73. def get_data(url):
  74.     response = requests.get(url)
  75.     return response.json()

  76. def send_data(url, data):
  77.     response = requests.post(url, json=data)
  78.     print(f"Response Status Code: {response.status_code}")
  79.     print(f"Response Status Text: {response.text}")


  80. if __name__ == '__main__':
  81.     raw_data = """
  82.     [   
  83.         {
  84.           "customerId": 123,
  85.           "callId": "03",
  86.           "startTimestamp": 1741755500000,
  87.           "endTimestamp": 1741755600000
  88.         },
  89.         {
  90.           "customerId": 123,
  91.           "callId": "02",
  92.           "startTimestamp": 1741564800000,
  93.           "endTimestamp": 1741755600000
  94.         },
  95.         {
  96.           "customerId": 123,
  97.           "callId": "01",
  98.           "startTimestamp": 1741669200000,
  99.           "endTimestamp": 1741672800000
  100.         },
  101.         {
  102.           "customerId": 123,
  103.           "callId": "0",
  104.           "startTimestamp": 1741564800000,
  105.           "endTimestamp": 1741651200000
  106.         },
  107.         {
  108.           "customerId": 123,
  109.           "callId": "1",
  110.           "startTimestamp": 1741582800000,
  111.           "endTimestamp": 1741586400000
  112.         },
  113.         {
  114.           "customerId": 123,
  115.           "callId": "2",
  116.           "startTimestamp": 1741586400000,
  117.           "endTimestamp": 1741590000000
  118.         },
  119.         {
  120.           "customerId": 123,
  121.           "callId": "3",
  122.           "startTimestamp": 1741582800000,
  123.           "endTimestamp": 1741590000000
  124.         },
  125.         {
  126.           "customerId": 123,
  127.           "callId": "4",
  128.           "startTimestamp": 1741564800000,
  129.           "endTimestamp": 1741755600000
  130.         },
  131.         {
  132.           "customerId": 111,
  133.           "callId": "111-1",
  134.           "startTimestamp": 1741564800000,
  135.           "endTimestamp": 1741651200001
  136.         }
  137.     ]
  138.     """

  139.     # 1741564800000 3-10 0am
  140.     # 1741582800000 3-10 5am
  141.     # 1741586400000 3-10 6am
  142.     # 1741590000000 3-10 7am

  143.     # 1741651200000 3-11 0am
  144.     # 1741669200000 3-11 5am
  145.     # 1741672800000 3-11 6am
  146.     # 1741676400000 3-11 7am

  147.     # 1741737600000 3-12 0am
  148.     # 1741755600000 3-12 5am

  149.     json_data = json.loads(raw_data)

  150.     ret = process_all_customer_for_all_day(json_data)

  151.     print(json.dumps(ret, indent=4))
  152. </div>
复制代码

评分

参与人数 2大米 +16 收起 理由
微信用户_6kkiv + 1 很有用的信息!
匿名用户-2TEYI + 15 欢迎分享你知道的情况,会给更多大米奖励!

查看全部评分


上一篇:凌鹰爱工程师电面
下一篇:Hubspot VO
🔗
cindyss 2025-5-4 02:45:23 | 只看该作者
全局:
公司组织架构的userKey是什么? 想看一下数据。
回复

使用道具 举报

🔗
诗意地栖息 2025-12-13 03:32:58 | 只看该作者
全局:
是codesignal上的OA吗?
回复

使用道具 举报

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

本版积分规则

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