My C solution works for "run code" but fails for "submit"


  • 0
    E
    struct ListNode* reverseList(struct ListNode* head) { 
      static struct ListNode* n = NULL; 
      if (!head) 
        return n; 
      else { 
        struct ListNode * temp = head->next; 
        head->next = n; 
        n = head; 
        return reverseList(temp); 
      }
    }
    

    I tested it by clicking "run code", it just works. But when i submit the code, the server says that the time limit exceeded for input [1,2]. Anyone knows what's going on? THX a lot :).


Log in to reply
 

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