Merge Sort Linked list

Problem : https://leetcode.com/problems/sort-list/
My solution : https://ide.codingblocks.com/s/321884

Please explain why I am getting error ?

Hey there are 2 corrections :
First on line 45 ,it should be return head because if we get some node whose next is NULL then in that case also its returning NULL

second correction is on line 33 it should be fast=head->next , because assume our linked list have 2 nodes only (1,2) so your code is giving mid as 2 and this means a=(1,2) and b=NULL so your program is stuck in infinite loop
making fast=head->next ensures that list is always broken down .
Please mark it as resolved if your code works :slight_smile: