PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Oura

Implement Server Number Allocation

Last updated: May 2, 2026

Quick Overview

This question evaluates the ability to design efficient stateful data structures and algorithms for resource allocation, focusing on management of per-type namespaces and correct reuse of released identifiers.

  • medium
  • Oura
  • Coding & Algorithms
  • Software Engineer

Implement Server Number Allocation

Company: Oura

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Implement a server number allocator for a data center. Servers have a string `type`, such as `"web"`, `"database"`, or `"cache"`. Each server type has its own independent namespace of positive integer server numbers starting from `1`. Design a class that supports the following operations efficiently: - `allocate(type: string) -> int`: Assign and return a server number for the given server type. - Return the smallest currently available positive integer for that type. - If no released number is available, assign the next new number for that type. - `release(type: string, number: int) -> void`: Release a previously allocated server number so it can be reused later for the same server type. Requirements: - Server numbers are independent across types. For example, `web` server `1` and `database` server `1` can both exist at the same time. - A number that is currently allocated must not be allocated again for the same type. - Released numbers should be reused before creating larger numbers, using the smallest available released number first. - Handle a large number of allocation and release requests efficiently. Example: ```text allocate("web") -> 1 allocate("web") -> 2 allocate("database") -> 1 release("web", 1) allocate("web") -> 1 allocate("web") -> 3 ```

Quick Answer: This question evaluates the ability to design efficient stateful data structures and algorithms for resource allocation, focusing on management of per-type namespaces and correct reuse of released identifiers.

Oura logo
Oura
Apr 1, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0
Loading...

Implement a server number allocator for a data center.

Servers have a string type, such as "web", "database", or "cache". Each server type has its own independent namespace of positive integer server numbers starting from 1.

Design a class that supports the following operations efficiently:

  • allocate(type: string) -> int : Assign and return a server number for the given server type.
    • Return the smallest currently available positive integer for that type.
    • If no released number is available, assign the next new number for that type.
  • release(type: string, number: int) -> void : Release a previously allocated server number so it can be reused later for the same server type.

Requirements:

  • Server numbers are independent across types. For example, web server 1 and database server 1 can both exist at the same time.
  • A number that is currently allocated must not be allocated again for the same type.
  • Released numbers should be reused before creating larger numbers, using the smallest available released number first.
  • Handle a large number of allocation and release requests efficiently.

Example:

allocate("web")      -> 1
allocate("web")      -> 2
allocate("database") -> 1
release("web", 1)
allocate("web")      -> 1
allocate("web")      -> 3

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Oura•More Software Engineer•Oura Software Engineer•Oura 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.