Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
Start free
Apply Pointer-Based Linked List Operations
00:00
5 left

Apply Pointer-Based Linked List Operations

MediumPython

Problem

Zscaler policy-processing code may maintain ordered rule identifiers in a mutable singly linked list. Implement a function that creates the list from initial values and applies a sequence of operations.

The supported operations are:

  1. insert_head, represented as ["insert_head", value]
  2. insert_tail, represented as ["insert_tail", value]
  3. delete, represented as ["delete", value], which removes only the first matching value if it exists
  4. reverse, represented as ["reverse"]

Return the final linked-list contents as a list. The linked list must be manipulated with node pointers. Do not use list insertion, deletion, or reversal to perform the operations.

Formal Specification

Implement linked_list_operations(values, operations), where values is a list of integers used to construct the initial singly linked list, and operations is a list of valid operation lists. Return a list of integers containing the final node values in order.

Constraints

  • 0 <= len(values) <= 10^4
  • 1 <= len(operations) <= 10^4
  • Values are integers in [-10^9, 10^9]
  • A delete operation removes only the first matching node
  • All operation names and formats are valid

Function Signature

def linked_list_operations(values, operations):
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

Sign up free to run or submit. Log in
Code
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 2
Run your code to see test output here.