...

/

Solution: Split a Circular Linked List

Solution: Split a Circular Linked List

Let’s solve the Split a Circular Linked List problem using the Fast and Slow pattern.

Statement

Given a circular linked list, list, of positive integers, your task is to split it into two circular linked lists. The first circular linked list should contain the first half of the nodes (exactly ⌈list.length / 2⌉ nodes), in the same order they appeared in the original list, while the second circular linked list should include the remaining nodes in the same order.

Return an array, answer, of length 2, where:

  • answer[0] is the circular linked list representing the first half.

  • answer[1] is the circular linked list representing the second half.

Note: A circular linked ...

Access this course and 1400+ top-rated courses and projects.