HubSpot software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question Your task is to implement a simple in-memory cloud storage system that maps objects (files) to their metadata (name, size, etc.). You...
Input: Graph (nodes and edges)Question Design a banking system that supports account management, transactions, and various financial operations.
Input: Graph (nodes and edges)Description Implement a simplified in-memory database that supports record manipulation with various operations. The system should handle basic...
Input: Graph (nodes and edges)Question A conference platform manages associations between events, attendees, and their roles. Each association is represented by three strings:...
Input: ListQuestion A streaming analytics platform needs to track peak viewership for each user on each day. You are given a list of Session records. Each...
customerId, teamId, callId, startTimestamp, and endTimestamp. Timestamps are decimal strings representing Unix milliseconds.[startTimestamp, endTimestamp): a call ending at a timestamp does not overlap one starting then.86400000 milliseconds. A call ending exactly at midnight contributes nothing to the following day.customerId, date, maxConcurrentCalls, the earliest timestamp attaining that maximum, and all callIds active at that timestamp.customerId lexicographically, then date. Sort each callIds list lexicographically. Output timestamps and counts are JSON integers.summarize_calls(calls: list[dict[str, str]]) -> candidate_chosen_typeExample 1:{
"calls": [
{"customerId":"A","teamId":"T","callId":"a","startTimestamp":"1000","endTimestamp":"5000"},
{"customerId":"A","teamId":"T","callId":"b","startTimestamp":"3000","endTimestamp":"7000"},
{"customerId":"A","teamId":"T","callId":"c","startTimestamp":"5000","endTimestamp":"9000"},
{"customerId":"B","teamId":"U","callId":"d","startTimestamp":"86398000","endTimestamp":"86402000"},
{"customerId":"B","teamId":"U","callId":"e","startTimestamp":"86400000","endTimestamp":"86403000"}
]
}[
{"customerId":"A","date":"1970-01-01","maxConcurrentCalls":2,"timestamp":3000,"callIds":["a","b"]},
{"customerId":"B","date":"1970-01-01","maxConcurrentCalls":1,"timestamp":86398000,"callIds":["d"]},
{"customerId":"B","date":"1970-01-02","maxConcurrentCalls":2,"timestamp":86400000,"callIds":["d","e"]}
]3000. At 5000, a ends as c starts, so concurrency remains two rather than becoming three. Call d contributes to both dates; e contributes only to January 2.Part 2 — Extensible capacity policiesscope, scopeId, and maxConcurrentCalls. Support customer scope, matching customerId, and team scope, matching teamId across all customers. Each record belongs to exactly one customer and one team, and a call may count toward both policies independently.Discuss how the return type changes before implementing this extension. Preserve the Part 1 results under customers and add policyResults. Your approach must be flexible enough to support additional policies and future scope kinds without rewriting the interval-processing algorithm.For every policy and date with matching positive-duration usage, emit:scope, scopeId, date, and integer limit from the policy.maxConcurrentCalls, earliest peak timestamp, and sorted peak callIds, using Part 1 semantics.overLimitMillis: total duration during which the scope's concurrency is strictly greater than its limit.excessCallMillis: the sum, over all constant-concurrency intervals, of max(0, concurrency - limit) * intervalDurationMillis.scope lexicographically, then scopeId lexicographically, then date. There is at most one policy for each (scope, scopeId) pair. Part 1 summaries remain present even for customers with no policy.Function signature: evaluate_billing(calls: list[dict[str, str]], policies: list[dict[str, str]]) -> candidate_chosen_typeExample 2:{
"calls": [
{"customerId":"A","teamId":"T","callId":"a","startTimestamp":"1000","endTimestamp":"5000"},
{"customerId":"A","teamId":"T","callId":"b","startTimestamp":"3000","endTimestamp":"7000"},
{"customerId":"B","teamId":"T","callId":"c","startTimestamp":"4000","endTimestamp":"6000"},
{"customerId":"B","teamId":"T","callId":"d","startTimestamp":"6000","endTimestamp":"8000"}
],
"policies": [
{"scope":"customer","scopeId":"A","maxConcurrentCalls":"1"},
{"scope":"team","scopeId":"T","maxConcurrentCalls":"2"}
]
}{
"customers": [
{"customerId":"A","date":"1970-01-01","maxConcurrentCalls":2,"timestamp":3000,"callIds":["a","b"]},
{"customerId":"B","date":"1970-01-01","maxConcurrentCalls":1,"timestamp":4000,"callIds":["c"]}
],
"policyResults": [
{"scope":"customer","scopeId":"A","date":"1970-01-01","limit":1,"maxConcurrentCalls":2,"timestamp":3000,"callIds":["a","b"],"overLimitMillis":2000,"excessCallMillis":2000},
{"scope":"team","scopeId":"T","date":"1970-01-01","limit":2,"maxConcurrentCalls":3,"timestamp":4000,"callIds":["a","b","c"],"overLimitMillis":1000,"excessCallMillis":1000}
]
}[3000,5000), giving 2000 over-limit milliseconds and (2-1)*2000 = 2000 excess-call milliseconds. Team T exceeds its limit only on [4000,5000), giving 1000 and (3-2)*1000 = 1000, respectively. At 6000, c ends and d starts; this does not create an additional peak or overage.Example 3:{
"calls": [
{"customerId":"A","teamId":"T","callId":"a","startTimestamp":"86399000","endTimestamp":"86402000"},
{"customerId":"A","teamId":"T","callId":"b","startTimestamp":"86400000","endTimestamp":"86402000"},
{"customerId":"A","teamId":"T","callId":"c","startTimestamp":"86400000","endTimestamp":"86401000"},
{"customerId":"B","teamId":"T","callId":"d","startTimestamp":"86402000","endTimestamp":"86403000"}
],
"policies": [
{"scope":"customer","scopeId":"A","maxConcurrentCalls":"1"},
{"scope":"team","scopeId":"T","maxConcurrentCalls":"1"}
]
}{
"customers": [
{"customerId":"A","date":"1970-01-01","maxConcurrentCalls":1,"timestamp":86399000,"callIds":["a"]},
{"customerId":"A","date":"1970-01-02","maxConcurrentCalls":3,"timestamp":86400000,"callIds":["a","b","c"]},
{"customerId":"B","date":"1970-01-02","maxConcurrentCalls":1,"timestamp":86402000,"callIds":["d"]}
],
"policyResults": [
{"scope":"customer","scopeId":"A","date":"1970-01-01","limit":1,"maxConcurrentCalls":1,"timestamp":86399000,"callIds":["a"],"overLimitMillis":0,"excessCallMillis":0},
{"scope":"customer","scopeId":"A","date":"1970-01-02","limit":1,"maxConcurrentCalls":3,"timestamp":86400000,"callIds":["a","b","c"],"overLimitMillis":2000,"excessCallMillis":3000},
{"scope":"team","scopeId":"T","date":"1970-01-01","limit":1,"maxConcurrentCalls":1,"timestamp":86399000,"callIds":["a"],"overLimitMillis":0,"excessCallMillis":0},
{"scope":"team","scopeId":"T","date":"1970-01-02","limit":1,"maxConcurrentCalls":3,"timestamp":86400000,"callIds":["a","b","c"],"overLimitMillis":2000,"excessCallMillis":3000}
]
}1000 milliseconds and two for another 1000: over-limit duration is 2000, while excess-call duration is (3-1)*1000 + (2-1)*1000 = 3000. Call c contributes to both policies simultaneously. At 86402000, A's remaining calls end before d is counted, so team concurrency becomes one and the overage stops.Notes:100000 calls and 100000 policies; call IDs are globally unique, IDs are nonempty, and inputs may be unsorted. Policy limits are integers from 0 through 100000.startTimestamp < endTimestamp, and each call lasts at most seven days. Epoch-era timestamps in the examples are synthetic fixtures.root and unlimited quota. Files and folders share a global ID namespace. Every non-root item has exactly one parent folder. IDs must be unique among live items; deleting an item permits its ID to be reused.-1 means unlimited; otherwise usage must not exceed the quota, including a quota of zero.false and change nothing. Invalid operations include missing IDs, a non-folder destination, duplicate IDs on creation, nonpositive file sizes, and quotas below -1. Lowering a quota below current usage fails.root, moving a folder into itself or a descendant, and any move that exceeds a destination ancestor's quota. Moving an item to its existing parent succeeds as a no-op. Common ancestors must be checked against the net change, not a temporary copy of the moved bytes.root or a missing item fails. Querying usage returns -1 for a missing ID or a file ID.MarketingAssetLibrary() — initialize the empty library.create_folder(folder_id: str, parent_id: str, quota: int = -1) -> bool — create an empty folder under an existing folder.upload(file_id: str, parent_id: str, size: int) -> bool — create a new file; overwriting an existing ID is not supported.move(item_id: str, destination_id: str) -> bool — move an existing file or folder into a folder.set_quota(folder_id: str, quota: int) -> bool — change a folder's quota, including the root quota.delete(item_id: str) -> bool — recursively delete a non-root item.usage(folder_id: str) -> int — return subtree file bytes, or -1 for an invalid folder ID.[ ["set_quota", "root", 60], ["create_folder", "drafts", "root", 50], ["create_folder", "published", "root", 40], ["upload", "hero-image", "drafts", 40], ["move", "hero-image", "published"], ["usage", "root"], ["usage", "drafts"], ["usage", "published"], ["upload", "email-banner", "drafts", 25], ["set_quota", "published", 30], ["usage", "root"] ]
[true, true, true, true, true, 40, 0, 40, false, false, 40]
drafts and adds 40 to published; the root's net change is zero. Uploading the banner would make root usage 40 + 25 = 65, exceeding 60, so nothing is created. Reducing published to 30 fails because its usage is 40.Example 2:[ ["create_folder", "campaign", "root", 100], ["create_folder", "email", "campaign", 30], ["upload", "logo", "email", 20], ["move", "campaign", "email"], ["move", "email", "campaign"], ["delete", "campaign"], ["usage", "root"], ["usage", "email"], ["upload", "logo", "root", 7], ["usage", "logo"], ["usage", "root"] ]
[true, true, true, false, true, true, 0, -1, true, -1, 7]
campaign into its descendant would create a cycle and fails. Moving email to its current parent succeeds without changes. Deleting campaign removes both folders and the 20-byte file, freeing the ID logo for reuse.Constraints:10^12 bytes; accumulated usage may exceed this value in unlimited folders. Nonpositive sizes and quotas below -1 must be rejected.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free