Implement a Reusable Locker Allocation System

Last updated: August 14, 2026

Quick Overview

Design and implement a reusable locker allocation system that supports 'store' and 'retrieve' operations, ensuring that the last allocated locker number is returned each time a locker is assigned.

Google
Coding & Algorithms
Software Engineer
Google
August 14, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

16

0

296 solved


Design and implement a reusable locker allocation system that supports 'store' and 'retrieve' operations, ensuring that the last allocated locker number is returned each time a locker is assigned.

This question is commonly asked during the technical screen round at Google to evaluate a candidate's coding and algorithmic skills. The interviewer is looking for the candidate's ability to design a system that efficiently manages resources (lockers) and handles operations in a way that optimizes for performance and usability. Candidates are expected to demonstrate their problem-solving approach and coding proficiency.

What the Interviewer Expects
  • Clear explanation of the problem and requirements.
  • Use of appropriate data structures for efficient allocation and retrieval.
  • Implementation of the 'store' and 'retrieve' functions with correct logic.
  • Handling edge cases, such as locker availability and reallocation.
  • Discussion of time and space complexity of the solution.
Key Topics to Cover
Data Structures
Algorithm Design
Complexity Analysis
Resource Management
System Design
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle a situation where all lockers are occupied?
  • What changes would you make if the system needs to support multiple types of lockers?
  • Can you explain how your solution scales with an increasing number of users?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

The locker allocation system needs to support two primary operations: store and retrieve. The store operation assigns a locker to a user and should return the locker number. The **retrieve...

High-Level Design

To implement this system, we can use a min-heap to manage available lockers efficiently. The min-heap allows us to always retrieve the smallest locker number available. A hash table will be us...


Submit Your Answer
Markdown supported

Related Questions