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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Banking System With Transfers
00:00
5 left

Banking System With Transfers

MediumPython

Problem

Implement an in-memory account processor for Circle USDC accounts. Process account creation, deposits, and transfers while ensuring invalid transfers are atomic and repeated operation IDs are idempotent.

Each operation has a unique operation_id. If the same ID is submitted again with the exact same operation data, return the original result without applying it again. If an existing ID is reused with different data, reject the operation.

Formal Specification

Implement process_operations(operations). operations is a list of arrays in one of these forms:

  • [operation_id, "CREATE", account_id]
  • [operation_id, "DEPOSIT", account_id, amount]
  • [operation_id, "TRANSFER", source_id, destination_id, amount]

Return an object with results, a Boolean result for each input operation, and balances, the final account balances. Account IDs and operation IDs are strings. All amounts are positive integers. New accounts start with balance 0.

A transfer succeeds only when both accounts exist, the accounts differ, and the source has enough funds. Failed operations must not modify any balance.

Constraints

  • 1 <= operations.length <= 2 * 10^5
  • Each operation has a unique ID unless it is an intentional retry
  • Account IDs and operation IDs are nonempty strings of at most 32 alphanumeric characters
  • Amounts are positive integers at most 10^9
  • Balances are nonnegative and fit in Python integers

Function Signature

def process_operations(operations):
Interviewer

Your question is Banking System With Transfers. 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.