More efficient approach

I solved this problem using 2 lists . Could you help me solving it more efficiently.

that is the efficient way, We can take two pointers before and after to keep track of the two linked lists as described above. These two pointers could be used two create two separate lists and then these lists could be combined to form the desired reformed list.

Algo :

  1. Take Two Fake_heads to take care of odd and even list.
  2. Put loop on the given LinkedList.
  3. If the node is odd add it to odd fake_ head list.
  4. If the node is Even add it to the even fake_head list.
  5. At the set connect both of the list together and set head to odd list.