Split a Circular Linked List into two halves
Submissions: 5276   Accuracy:

48.61%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Interview Preparation

Given a Cirular Linked List split it into two halves circular lists. If there are odd number of nodes in the given circular linked list then out of the resulting two halved lists, first list should have one node more than the second list. The resultant lists should also be circular lists and not linear lists.

Input:

You have to complete the method which takes 3 argument: The address of the head of the linked list , addresses of the head of the first and second halved resultant lists.. You should not read any input from stdin/console. There are multiple test cases. For each test case, this method will be called individually.

Output:


Set the *head1_ref and *head2_ref to first resultant list and second resultant list respectively.


Constraints:

1<=T<=100
2<=N<=100


Example:

Input:
2
3
1 5 7
4
2 6 1 5

Output:
1 5
7
2 6
1 5



Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: bhawnamait


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.