Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Supply Chain Inventory Data Structure
00:00
5 left

Supply Chain Inventory Data Structure

HardPython

Problem

Design an in-memory data structure that can efficiently track and update supply chain inventory levels across multiple nodes.

Implement inventory_operations(operations). Each operation is a dictionary representing an inventory update, transfer, or query. Return query results in encounter order. Support update, transfer, stock, total, and node_total operations. Inventory quantities must never become negative, and all operation inputs are valid.

update changes one SKU at one node by a signed delta. transfer moves a positive quantity between two nodes. Query operations return integer quantities.

Constraints

  • 1 <= operations.length <= 5000
  • Node and SKU names are non-empty strings
  • Update deltas are integers
  • Transfer quantities are positive integers
  • Every operation leaves all inventory quantities nonnegative
  • Each operation is one of update, transfer, stock, total, or node_total

Function Signature

def inventory_operations(operations):
Interviewer

Your question is Supply Chain Inventory Data Structure. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.