To group all the odd and the even nodes together, first, you need to find out where will the odd node start and where it ends, and the same goes for the even nodes; after that, connect the end of the odd list to the beginning of the event list. And after that, mark the end of the even linked list as Null. This code has a time complexity of order O(N) as you use a loop to traverse, and the space complexity will be O(1) as no extra space is needed, and only a few pointers are stored.