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
Design a CRUD Backend
00:00
5 left

Design a CRUD Backend

MediumPython

Problem

Design a CRUD based application (backend only). This was asked in the Take-home assignment stage, Take-home round 1; the candidate implemented it in JavaScript and Node.js. The fuller prompt was: "Design a CRUD based application (Backend only) for railway reservation system."

Implement process_reservations(operations). Each operation is a dictionary with action (create, read, update, or delete) and reservation_id; create operations also include passenger, train, and seat. Return one result per operation: the reservation for successful create, read, or update, True or False for delete, and None for invalid or missing records.

Example: creating R1 returns its record; reading R1 returns the same record.

Constraints

  • 1 <= operations.length <= 1000
  • Each reservation_id is a non-empty string
  • Each create operation contains passenger, train, and seat
  • Reservation IDs are unique among simultaneously active reservations
  • Updates modify only passenger, train, and seat

Function Signature

def process_reservations(operations):
Interviewer

Your question is Design a CRUD Backend. 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.