PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/HubSpot

Validate hiring request under role constraints

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to enforce cardinality constraints and manage state across related entities, testing competencies in data consistency, edge-case handling, and algorithmic efficiency when tracking assignments.

  • medium
  • HubSpot
  • Coding & Algorithms
  • Software Engineer

Validate hiring request under role constraints

Company: HubSpot

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are building a simple HR assignment validator for a platform with **companies**, **employees**, and **job roles**. When the system receives a request to assign an employee to a role in a company, it must enforce the following rules: 1. **Role capacity per company:** In a given company, **each role** can be held by **at most 5 employees** at the same time. 2. **Max roles per employee per company:** An employee can hold **at most 2 roles in the same company** at the same time. If a request violates any rule, the system must return `invalid` and also provide a **reason**. Otherwise, it should apply the assignment and return `valid`. ## Input - An initial set of existing assignments. - A sequence of `add` requests, each of the form: - `employee_id`, `company_id`, `role_name` ## Output For each `add` request, output either: - `valid` (and the assignment is applied), or - `invalid: <reason>` where `<reason>` clearly states which rule was violated. ## Notes / Clarifications - If an employee is already assigned to the same role in the same company, treat it as `valid` (no-op), unless you choose to define it as an error—state your assumption. - If both rules would be violated, you may return either a single reason or multiple reasons, but be consistent. ## Constraints (you may assume) - Up to `10^5` total assignments and requests. - IDs/role names are strings. ## Example (illustrative) Given existing assignments where role `SWE` at company `C1` already has 5 employees, adding another `SWE` to `C1` should return: - `invalid: role capacity exceeded (max 5 per role per company)`

Quick Answer: This question evaluates the ability to enforce cardinality constraints and manage state across related entities, testing competencies in data consistency, edge-case handling, and algorithmic efficiency when tracking assignments.

Related Interview Questions

  • Find a special person using knows(a,b) - HubSpot (easy)
  • Design and implement a bank account system - HubSpot (Medium)
  • Design file deduplication at scale - HubSpot (Medium)
  • Design a bank with scheduled payments and merges - HubSpot (Medium)
  • Implement Python LRU cache with varargs - HubSpot (Medium)
HubSpot logo
HubSpot
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
20
0
Loading...

Problem

You are building a simple HR assignment validator for a platform with companies, employees, and job roles.

When the system receives a request to assign an employee to a role in a company, it must enforce the following rules:

  1. Role capacity per company: In a given company, each role can be held by at most 5 employees at the same time.
  2. Max roles per employee per company: An employee can hold at most 2 roles in the same company at the same time.

If a request violates any rule, the system must return invalid and also provide a reason. Otherwise, it should apply the assignment and return valid.

Input

  • An initial set of existing assignments.
  • A sequence of add requests, each of the form:
    • employee_id , company_id , role_name

Output

For each add request, output either:

  • valid (and the assignment is applied), or
  • invalid: <reason> where <reason> clearly states which rule was violated.

Notes / Clarifications

  • If an employee is already assigned to the same role in the same company, treat it as valid (no-op), unless you choose to define it as an error—state your assumption.
  • If both rules would be violated, you may return either a single reason or multiple reasons, but be consistent.

Constraints (you may assume)

  • Up to 10^5 total assignments and requests.
  • IDs/role names are strings.

Example (illustrative)

Given existing assignments where role SWE at company C1 already has 5 employees, adding another SWE to C1 should return:

  • invalid: role capacity exceeded (max 5 per role per company)

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More HubSpot•More Software Engineer•HubSpot Software Engineer•HubSpot Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.