My simple C++ recursively solution.

  • 0
    ListNode* reverseList(ListNode* head) {
    	if(head == NULL) return head;
        ListNode* ans = NULL;
    	if(head->next == NULL) return head;
    	else ans = reverseList(head->next);
    	head->next->next = head;
    	head->next = NULL;
    	return ans;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.