最近收到了HubSpot实习的OA, 请问谁有面经?请大家分享面经?
请问你是海投的嘛?@@
是海投
一直听说hubspot 不错,linkedin上面的排名也很高,工资我查了下glassdoor也不错,在麻省能给和湾区差不多的工资,感觉很好了。
公司文化听说不错,面试和柏林的hr聊天,也很愉快。
HubSpot develops cloud-based, inbound marketing software that allows businesses to transform the way that they market online. 都E轮了 https://www.crunchbase.com/organization/hubspot#section-overview
然后收到了oa,oa是论坛里说过的api类题目,其实难点主要是json的处理,看你对json的library熟练与否。
限时三小时。一开始没准备好,打开后set up environment 花了一些时间,没做完,就算了。整体感觉还是很简单的一个oa。1-2小时内完成比较competitive。
OA就这一题。要求针对每个国家,找出连续的两天,使得该国家可参加的人数最多。
把结果封装成json,POST到第二个API中去,response code为500时,答案正确。
oa 会给你一个token,用来get 和post,这个我就不分享了,我想应该是每个人会有一个独立的token。
你会拿到的json 是这样的
"partners": [
{
"firstName": "Darin",
"lastName": "Daignault",
"email": "ddaignault@hubspotpartners.com",
"country": "United States",
"availableDates": [
"2017-05-03",
"2017-05-06"
},
...
你会拿到很多partner,来自不同的国家。
你要求提交的result是这样的
"countries": [
{
"attendeeCount": 1,
"attendees": [
"cbrenna@hubspotpartners.com"
],
"name": "Ireland",
"startDate": "2017 -04-29"
},
]
然后你需要一个get 拿json 和一个post 返回结果。整体不难的,祝大家好运。
import requests
import json
def get_data(url):
data = requests.get(url).json()
return data
def check_consecutive(s1, s2):
import datetime
s1 = datetime.datetime.strptime(s1, "%Y-%m-%d")
s2 = datetime.datetime.strptime(s2, "%Y-%m-%d")
return (s2 - s1).days == 1
def check_prev(s1, s2):
import datetime
s1 = datetime.datetime.strptime(s1, "%Y-%m-%d")
s2 = datetime.datetime.strptime(s2, "%Y-%m-%d")
return (s1 - s2).days >= 1
def find_overlap(res, dates, country):
if not dates:
res["countries"].append({
"attendeeCount": 0,
"attendees": [],
"name": country,
"startDate": None
})
else:
best_len = 0
best_date = ""
for key in dates:
if not best_date:
best_len = max(best_len, len(dates[key]))
best_date = key
elif len(dates[key]) > best_len:
best_len = len(dates[key])
best_date = key
# Check whether this day is earlier than the best_date we have so far
elif len(dates[key]) == best_len and check_prev(best_date, key):
best_date = key
res["countries"].append({
"attendeeCount": len(dates[best_date]),
"attendees": list(dates[best_date]),
"name": country,
"startDate": best_date
})
def post_data(post_url, get_url):
from collections import defaultdict
data = get_data(get_url)
countries = defaultdict(list)
for person in data["partners"]:
country = person["country"]
countries[country].append(person)
res = {"countries": []}
# Sort people by countries
for country in countries:
dates = defaultdict(set)
for person in countries[country]:
p_date = person["availableDates"]
for j in range(1, len(p_date)):
if check_consecutive(p_date[j - 1], p_date[j]):
dates[p_date[j - 1]].add(person["email"])
# Find overlap
find_overlap(res, dates, country)
resp = requests.post(post_url, json=res)
if resp.status_code != 200:
print(resp.status_code, resp.content)
print(resp.status_code == 200)
get_url = "https://candidate.hubteam.com/candidateTest/v3/problem/dataset?userKey=1cae96d3904b260d06d0daa7387c"
post_url = "https://candidate.hubteam.com/candidateTest/v3/problem/result?userKey=1cae96d3904b260d06d0daa7387c"
post_data(post_url, get_url)