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
Linked List Implementation
00:00
5 left

Linked List Implementation

MediumPython

Problem

The international advanced analytics data platform needs an in-memory sequence structure for workloads with frequent insertions and removals at both ends. Implement a mutable doubly linked list and process a sequence of commands while preserving correct head, tail, and length invariants.

Formal Specification

Write process_linked_list(operations), where operations is a list of command arrays. Return a list containing results only for commands that produce output:

  • ['append', value]: Add value to the end.
  • ['prepend', value]: Add value to the beginning.
  • ['insert', index, value]: Insert at index, returning true if valid and false otherwise.
  • ['get', index]: Return the value at index, or null if invalid.
  • ['delete', index]: Remove and return the value at index, or null if invalid.
  • ['pop_front'] and ['pop_back']: Remove and return an end value, or null when empty.
  • ['reverse']: Reverse the list in place.
  • ['length']: Return the current number of elements.

Values are integers. Indexing is zero-based. insert accepts indices from 0 through the current length.

Constraints

  • 1 <= len(operations) <= 10^5
  • -10^9 <= value <= 10^9
  • Each command has valid syntax and a recognized operation name
  • Indices are integers and may be outside the current valid range
  • The list must maintain correct head, tail, prev, next, and length invariants

Function Signature

def process_linked_list(operations):
Interviewer

Your question is Linked List Implementation. 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.