PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/Pinterest

Design adjustable ID allocator

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design data structures, APIs, and algorithms for constrained resource allocation, focusing on contiguous range management, resizing semantics, and time/space complexity reasoning.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Software Engineer

Design adjustable ID allocator

Company: Pinterest

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You manage an integer ID space [0, 999] and N named buckets in a fixed order. Implement two operations: ( 1) allocate(buckets: List<(name, desired_size)>) -> List<(name, start_id, end_id)> that assigns contiguous, non-overlapping ranges to buckets from low to high IDs, preserving the given order, and fails if the sum of desired sizes exceeds 1000; ( 2) resize(name, new_desired_size) that grows or shrinks the specified bucket’s range and minimally shifts only adjacent ranges while keeping all ranges contiguous, disjoint, in order, and within [0, 999]; if the total desired size exceeds capacity, return a clear error. Define the data structures, APIs, and time/space complexity, and describe how you would test boundary cases such as empty buckets, full utilization, and expansions that would overflow capacity.

Quick Answer: This question evaluates a candidate's ability to design data structures, APIs, and algorithms for constrained resource allocation, focusing on contiguous range management, resizing semantics, and time/space complexity reasoning.

Related Interview Questions

  • Solve Multiple Coding Interview Problems - Pinterest (medium)
  • Implement a Sparse Matrix Class - Pinterest (medium)
  • Assign Pins to Shortest Columns - Pinterest (medium)
  • Design Hierarchical Permission Checks - Pinterest (medium)
  • Implement weighted random choice - Pinterest (medium)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
8
0

You manage an integer ID space [0, 999] and N named buckets in a fixed order. Implement two operations: (

  1. allocate(buckets: List<(name, desired_size)>) -> List<(name, start_id, end_id)> that assigns contiguous, non-overlapping ranges to buckets from low to high IDs, preserving the given order, and fails if the sum of desired sizes exceeds 1000; (
  2. resize(name, new_desired_size) that grows or shrinks the specified bucket’s range and minimally shifts only adjacent ranges while keeping all ranges contiguous, disjoint, in order, and within [0, 999]; if the total desired size exceeds capacity, return a clear error. Define the data structures, APIs, and time/space complexity, and describe how you would test boundary cases such as empty buckets, full utilization, and expansions that would overflow capacity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 7,500+ 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.