@tusizi So during each iteration, we created two ListNodes. How will this influence the space. Will this influence the requirement of "using constant space"? Thanks!

@caikehe
hello dear frend ,i am so confusion of this
ListNode *nxt = head->next;
head->next = nxt->next;
nxt->next = head;
node->next = nxt;
node = head;
head = node->next;
can you show me in picture about it work?
thank you so much !!!!!!!!

The recursion is nice and the code is compact but the condition was: "Your algorithm should use only constant space.". When using the recursion u use linear space because you will call n/2 times recursively the method and you will create a n/2 size stack where n is the size of the list.