HubSpot’s Online Assessment for internship and new graduate Software Engineer roles evaluates candidates’ problem-solving skills, coding fundamentals, and ability to handle real-world engineering scenarios. The assessment often includes algorithmic coding challenges, debugging tasks, and scenario-based questions.
Problem description:
Responsibility — So, you have to implement a new view of the analytics: sessions. The workload is a data set of individual web page visits, and this comes with an accompanying visitorId generated by their tracking cookie which identifies each unique user. The purpose is to create a list of sessions for each visitor from that data.
The raw event data is available at REDACTED via the dataset API
The data set looks like this:
"events": [
{
"url": "/pages/a-big-river",
"visitorId": "d1177368-2310-11e8-9e2a-9b860a0d9039",
"timestamp": 1512754583000
},
{
"url": "/pages/a-small-dog",
"visitorId": "d1177368-2310-11e8-9e2a-9b860a0d9039",
"timestamp": 1512754631000
},
{
"url": "/pages/a-big-talk",
"visitorId": "f877b96c-9969-4abc-bbe2-54b17d030f8b",
"timestamp": 1512709065294
},
{
"url": "/pages/a-sad-story",
"visitorId": "f877b96c-9969-4abc-bbe2-54b17d030f8b",
"timestamp": 1512711000000
},
{
"url": "/pages/a-big-river",
"visitorId": "d1177368-2310-11e8-9e2a-9b860a0d9039",
"timestamp": 1512754436000
},
{
"url": "/pages/a-sad-story",
"visitorId": "f877b96c-9969-4abc-bbe2-54b17d030f8b",
"timestamp": 1512709024000
}
]
}
With the input data, we would like to generate sessions from this incoming data. You have the CSV of all your recorded user activity, defining a session as a bunch of events from a single visitor with 10 minutes apart between each event. A visitor may have more than one session.
Therefore for the example input data above, we should get something like:
"sessionsByUser": {
"f877b96c-9969-4abc-bbe2-54b17d030f8b": [
{
"duration": 41294,
"pages": [
"/pages/a-sad-story",
"/pages/a-big-talk"
],
"startTime": 1512709024000
},
{
"duration": 0,
"pages": [
"/pages/a-sad-story"
],
"startTime": 1512711000000
}
],
"d1177368-2310-11e8-9e2a-9b860a0d9039": [
{
"duration": 195000,
"pages": [
"/pages/a-big-river",
"/pages/a-big-river",
"/pages/a-small-dog"
],
"startTime": 1512754436000
}
]
}
}
After you get your event data, transform it into sessions and POST the result to REDACTED via HTTP
Approach
Our approach was firstly to:
- Map
visitorId→ list of visits (url, timestamp) in a map. - Fill that map with data from the GET URL.
- Sort each visitor’s list by timestamp ascending. Then iterate:
- If current session is empty, start a new one and record startTime.
- Else, check the time gap to the previous event:
- ≤ 10 minutes: add to current session.
- > 10 minutes: close current session, start a new one.
- Calculate session fields:
- startTime: timestamp of first event.
- duration: lastEventTime − firstEventTime.
- pages: ordered list of URLs in session.
- Compile sessions for all users into the final JSON and POST to the API.
Frequently Asked Questions – HubSpot OA
Q1: What types of questions appear in the HubSpot SDE New Grad OA?
A: The OA usually includes a mix of algorithmic coding problems, debugging tasks, and scenario-based questions that reflect real-world engineering challenges. Examples include string manipulation, session or event processing, data transformations, and API interaction.
Q2: How long is the HubSpot OA, and how many problems are there?
A: Typically, the OA is 90–120 minutes long and contains 2–3 coding problems. Passing at least two problems is generally required to move forward to interviews.
Q3: Do I need to know any specific programming language?
A: You can usually choose from Python, Java, JavaScript, or C++. Candidates often prefer Python for its concise syntax and built-in libraries, but efficiency and correctness matter more than language choice.
Q4: How is a session defined in the event-processing problem?
A: A session is a series of events from a single visitor where consecutive events are no more than 10 minutes apart. Each visitor can have multiple sessions, and each session should include startTime, duration, and an ordered list of pages.
Q5: How should I handle edge cases in the HubSpot OA?
A: Make sure to account for:
- Events with exactly 10 minutes apart.
- Single-event sessions.
- Out-of-order timestamps (always sort events before processing).
- Multiple sessions per visitor.
Q6: Does the OA involve API calls or just data processing?
A: Some scenario-based questions may require transforming data and submitting results via a POST request, simulating real engineering workflows. You should focus on both correctness and efficient data handling.
Q7: How can I prepare effectively for HubSpot OA?
A:
- Practice array, string, and hash map problems.
- Understand time gap/session logic for event-processing questions.
- Review sorting, dictionaries, and JSON manipulation.
- Use platforms like HackerRank to simulate timed assessments.
Reference
The HubSpot coding assessment
HubSpot OA
If you also need our interview assistance services or OA support services, please contact us immediately.