PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Pinterest

Design ID allocator with resizable bucket ranges

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's proficiency in interval and resource-allocation algorithms, deterministic conflict-resolution policies, data structure selection for range management, time/space complexity analysis, and concurrency control.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Software Engineer

Design ID allocator with resizable bucket ranges

Company: Pinterest

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Given a fixed global ID space [0, 999] and an initial list of bucket specifications, where each bucket has a unique name and an inclusive ID range [start, end], implement two functions: ( 1) assign(buckets): validate and normalize the ranges so they are within bounds, non-overlapping, and returned as a sorted array of {name, start, end}; leave any unassigned IDs free. ( 2) resize(buckets, name, desired_size): adjust the array so bucket 'name' has exactly desired_size IDs by expanding or shrinking its range while preserving non-overlap and staying within [0, 999]. Prefer consuming immediately adjacent free space; if insufficient, borrow from neighboring buckets using a deterministic policy (e.g., take from the nearest bucket with the largest surplus). If the request cannot be satisfied, return an error. Describe your data structures, the time/space complexity of typical operations, and how you would handle concurrent calls or conflicting resize requests.

Quick Answer: This question evaluates a candidate's proficiency in interval and resource-allocation algorithms, deterministic conflict-resolution policies, data structure selection for range management, time/space complexity analysis, and concurrency control.

Related Interview Questions

  • Maximize Boxes Stored Through One Entrance - Pinterest (medium)
  • 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)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
5
0

Given a fixed global ID space [0, 999] and an initial list of bucket specifications, where each bucket has a unique name and an inclusive ID range [start, end], implement two functions: (

  1. assign(buckets): validate and normalize the ranges so they are within bounds, non-overlapping, and returned as a sorted array of {name, start, end}; leave any unassigned IDs free. (
  2. resize(buckets, name, desired_size): adjust the array so bucket 'name' has exactly desired_size IDs by expanding or shrinking its range while preserving non-overlap and staying within [0, 999]. Prefer consuming immediately adjacent free space; if insufficient, borrow from neighboring buckets using a deterministic policy (e.g., take from the nearest bucket with the largest surplus). If the request cannot be satisfied, return an error. Describe your data structures, the time/space complexity of typical operations, and how you would handle concurrent calls or conflicting resize requests.

Submit Your Answer

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 8,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.