vendredi 8 octobre 2021

Split the singly linked list into two in a specific manner

hello im stuck in this problem so if anyone can guide me how to solve this problem it can help me a lot.

Write a program in C++ to split the nodes of a given singly linked list into the front and back halves such that the back halve elements are stored in reverse order.

Ex- {1, 3, 4, 6, 2, 3, 8, 9} --> {1, 3, 4, 6} and {9, 8, 3, 2}

Sample Input

1 3 4 6 2 3 8 9

Sample Output

1 3 4 6

9 8 3 2

Aucun commentaire:

Enregistrer un commentaire