Never mind just fixed it! Instead of setting while loop to check if (head->next!=NULL) I just changed it to while(head!=NULL) and put the last if statement inside the while loop.
Excuse me, may I ask that which line is Line#36 ?
This error also occurs in my coding(the same problem) and I still don't know why ,so I cannot fix it.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.