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)s and a positive...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 remote-work platform needs to schedule weekly standups for distributed teams. Each team member provides a list of dates (formatted as...
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...
text containing only lowercase English letters and a positive integer k, find the substring of length k that appears most...Input: Graph (nodes and edges)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.LRUCache which supports get and put operations. The get method should retrieve a value from the cache if it exists, marking it as recently used. The put method should insert a value into the cache; if the cache exceeds its capacity, it should evict the least recently used item. The capacity of the cache will be provided upon initialization.class LRUCache:def __init__(self, capacity: int) -> None: # Initialize the LRUCache with positive size capacity.def get(self, key: int) -> int: # Return the value of the key if the key exists, otherwise return -1.def put(self, key: int, value: int) -> None: # Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity, evict the least recently used key.cache = LRUCache(2)cache.put(1, 1)cache.put(2, 2)cache.get(1) → Output: 1 (The cache is now {1=1, 2=2})1 is retrieved successfully, confirming it is in cache.cache.put(3, 3)cache.get(2) → Output: -1 (The cache is now {1=1, 3=3})3 evicts 2 which is the least recently used item.1 <= capacity <= 30000 <= key <= 100000 <= value <= 10000get and put will be called at most 10^4 times.def add_task(self, task_id: int, name: str) -> None:def mark_complete(self, task_id: int) -> None:def get_active_tasks(self) -> List[str]:add_task(1, "Design UI")Noneadd_task(2, "Develop Backend")Noneget_active_tasks()['Design UI', 'Develop Backend']mark_complete(1)Noneget_active_tasks()['Develop Backend']add_task(3, "Testing")Noneadd_task(4, "Deployment")Nonemark_complete(3)Noneget_active_tasks()['Deployment']id, title, description, status, and a timestamp for creation. create_task(title: str, description: str) -> int update_task(task_id: int, title: Optional[str] = None, description: Optional[str] = None, status: Optional[str] = None) -> bool delete_task(task_id: int) -> bool get_task(task_id: int) -> Optional[Dict[str, Any]] create_task("Fix bug", "Address issue #123") 1 1. update_task(1, status="completed") True 1 is updated to completed. title, description, and a completed state. Implement the following methods:add_task(title: str, description: str) -> Nonecomplete_task(title: str) -> Noneget_pending_tasks() -> List[Dict[str, Union[str, bool]]]add_task(title: str, description: str) -> Nonecomplete_task(title: str) -> Noneget_pending_tasks() -> List[Dict[str, Union[str, bool]]]add_task("Task 1", "Description for Task 1") None get_pending_tasks() [{'title': 'Task 1', 'description': 'Description for Task 1', 'completed': False}]Example 2: add_task("Task 2", "Description for Task 2") None complete_task("Task 2") None get_pending_tasks() [{'title': 'Task 1', 'description': 'Description for Task 1', 'completed': False}]Constraints:TaskManager, that can manage tasks for a project. The tasks should include methods to add tasks, mark them as completed, retrieve all tasks, and filter completed and active tasks.def add_task(self, task_id: int, task_description: str) -> None:def mark_completed(self, task_id: int) -> None:def get_all_tasks(self) -> List[Dict[str, Union[int, str, bool]]]:def get_completed_tasks(self) -> List[Dict[str, Union[int, str, bool]]]:task_manager.add_task(1, "Write proposal")Nonetask_manager.mark_completed(1)NoneTaskManager that allows you to track all tasks and their states. Each task can be either Open, In Progress, or Completed. The class should provide functionalities to add new tasks, update their states, and retrieve the percentage of tasks that have been completed. Task IDs should be unique integers, and you must manage these in a list internally.def __init__(self): -> Nonedef add_task(self, task_id: int, task_name: str) -> None:def update_task(self, task_id: int, status: str) -> None:def get_completion_percentage(self) -> float:tm.add_task(1, "Write Blog Post") None tm.add_task(2, "Develop Feature") None Input: tm.update_task(1, "In Progress") None Input: tm.update_task(2, "Completed") None Input: tm.get_completion_percentage() 50.0 tm.add_task(3, "Review Code") None Input: tm.update_task(3, "Completed") None Input: tm.get_completion_percentage() 66.67 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.TaskManager that allows users to manage tasks. Each task should have an ID, title, description, and a status. The TaskManager should allow adding, removing, and updating tasks, as well as retrieving all tasks in a specified status.def add_task(title: str, description: str) -> int: def remove_task(task_id: int) -> bool: def update_task(task_id: int, title: Optional[str] = None, description: Optional[str] = None, status: Optional[str] = None) -> bool: def get_tasks_by_status(status: str) -> List[Dict[str, Union[int, str]]]: Example 1: tm = TaskManager() tm.add_task("Write documentation", "Create user guides and API docs") 1 1.Example 2: tm.update_task(1, status="completed") True 1 is successfully updated to completed.Constraints: 1. ['pending', 'in_progress', 'completed']. 1000. Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free