PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Visa

Design rotating warehouse simulator with closures

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic skills in designing efficient dynamic data structures and performing event-driven simulation with mutable state, specifically managing cyclic capacity resets and permanent closures in the Coding & Algorithms domain.

  • Medium
  • Visa
  • Coding & Algorithms
  • Software Engineer

Design rotating warehouse simulator with closures

Company: Visa

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Given an integer array cap[0..n-1] for warehouses 0..n-1 and a sequence of events, simulate package processing. Events: ( 1) "PACKAGE": process one package by assigning it to the first warehouse at or after the current pointer (initially 0) that is not permanently closed and has remaining capacity in the current cycle; when a warehouse hits its capacity in the current cycle, it is considered full and skipped until the next cycle; advance the pointer to the next eligible warehouse after each package. ( 2) "CLOSURE x": permanently close warehouse x so it never processes packages again. Cycle reset: when warehouse n-1 becomes full and there is no eligible warehouse afterward in the current cycle, the next PACKAGE begins a new cycle where remaining capacities of all non-closed warehouses reset to cap[i]; closures persist. After processing all events, return the id of the warehouse that processed the most packages; break ties by returning the largest id. Design data structures and an algorithm with low per-event complexity and describe edge cases (e.g., if all warehouses are closed).

Quick Answer: This question evaluates algorithmic skills in designing efficient dynamic data structures and performing event-driven simulation with mutable state, specifically managing cyclic capacity resets and permanent closures in the Coding & Algorithms domain.

Related Interview Questions

  • Solve Two Algorithm Challenges - Visa (hard)
  • Solve Three Array Coding Problems - Visa (medium)
  • Maintain pair-sum counts under replacements - Visa (Medium)
  • Compute distinct sums from limited coins - Visa (Medium)
Visa logo
Visa
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
11
0

Given an integer array cap[0..n-1] for warehouses 0..n-1 and a sequence of events, simulate package processing. Events: (

  1. "PACKAGE": process one package by assigning it to the first warehouse at or after the current pointer (initially
  2. that is not permanently closed and has remaining capacity in the current cycle; when a warehouse hits its capacity in the current cycle, it is considered full and skipped until the next cycle; advance the pointer to the next eligible warehouse after each package. (
  3. "CLOSURE x": permanently close warehouse x so it never processes packages again. Cycle reset: when warehouse n-1 becomes full and there is no eligible warehouse afterward in the current cycle, the next PACKAGE begins a new cycle where remaining capacities of all non-closed warehouses reset to cap[i]; closures persist. After processing all events, return the id of the warehouse that processed the most packages; break ties by returning the largest id. Design data structures and an algorithm with low per-event complexity and describe edge cases (e.g., if all warehouses are closed).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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