• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 18, 2024 |240 Views

PROBLEM OF THE DAY : 17/10/2024 | Split Linked List Alternatingly

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Ayush Tripathi We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Linked List but also build up problem-solving skills.

Given a singly linked list's head. Your task is to complete the function alternatingSplitList() that splits the given linked list into two smaller lists. The sublists should be made from alternating elements from the original list.
Note: 

  • The sublist should be in the order with respect to the original list.
  • Your have to return an array containing the both sub-linked lists.

Examples:

Input: LinkedList = 0->1->0->1->0->1
Output: 0->0->0 , 1->1->1
Explanation: After forming two sublists of the given list as required, we have two lists as: 0->0->0 and 1->1->1.
 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/split-singly-linked-list-alternatingly/1