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
Mobile User List Class Structure
00:00
5 left

Mobile User List Class Structure

EasyPython

Problem

Design a small in-memory user directory for an Air Apps mobile application. Implement CRUD-style operations while ensuring user IDs remain unique and listing users preserves their insertion order.

Formal Specification

Implement process_user_operations(operations). Each operation is a dictionary with an action field:

  1. {"action": "add", "user": {"id": string, "name": string, "email": string}}: Add a user and return true. If the ID already exists, return false.
  2. {"action": "update", "user": {"id": string, "name": string, "email": string}}: Replace an existing user record and return true. If the ID does not exist, return false.
  3. {"action": "remove", "id": string}: Remove a user and return true if one existed, otherwise false.
  4. {"action": "get", "id": string}: Return the user dictionary, or null if absent.
  5. {"action": "list"}: Return all users in insertion order.

Return an array containing one result for every operation. Use a class internally to encapsulate the directory state.

Constraints

  • 1 <= len(operations) <= 10^5
  • Each user ID, name, and email is a non-empty string
  • User IDs are unique among successfully added users
  • Inputs follow the specified operation formats

Function Signature

def process_user_operations(operations):
Interviewer

Your question is Mobile User List Class 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.