Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Easy Accuracy: 49.14% Submissions: 14534 Points: 2

Given a singly linked list, the task is to rearrange it in a way that all odd position nodes are together and all even positions node are together.
Assume the first element to be at position 1 followed by second element at position 2 and so on.

Example 1:

Input:
Output: 1 3 2 4


Example 2:

Input:
Output: 1 3 5 2 4

The task is to complete the function rearrangeEvenOdd() which rearranges the nodes in the linked list as required and return the head of the linked list.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:
1 <= Size of the linked list <= 10000
1 <= values of linked list<= 1000