Where is the problem: The case for 1,2 I can test correctly on my complier why here not correctly?

  • 0

    struct ListNode* reverseList(struct ListNode* head) {

    if(head == NULL)
    	return head;
    struct ListNode *cur = head->next, *cur_next = NULL;
    head->next = NULL;
    while(cur != NULL)
    	cur_next = cur->next;
    	cur->next = head->next;
    	head->next = cur;
    	cur = cur_next;
    return head;


Log in to reply

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