Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Reverse a Patient Queue List

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Reverse a Patient Queue List. Start with the requirements on the right.

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.

Problem

In a Syneos Health workflow, a patient processing queue may be represented as a singly linked list. Write a function that reverses the linked list in place and returns the new head.

You are given the head of a singly linked list, where each node contains a value and a pointer to the next node. Return the head of the reversed list.

Formal Specification

  • Input: head, the first node of a singly linked list, or None for an empty list
  • Output: The new head node after reversing the list
  • You must reverse the existing links rather than creating a second list of copied nodes.

Constraints

  • 0 <= number of nodes <= 10^5
  • -10^9 <= node.val <= 10^9
  • The input list is singly linked
  • The solution should reverse pointers in place

Function Signature

def reverse_linked_list(head):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output