Runtime error in Pallindrome Linked List


  • 0
    R

    here is my code..I am getting runtime error

    bool isPalindrome(ListNode* head) {
        if (head == NULL) {
            return true;
        } else {
            return find(head);
        }
    }
    
    bool find(ListNode* head) {
        static ListNode *tmp = head;
        
        if (head == NULL) {
            return true;
        }
        
        bool res = find(head->next);
        
        if (res == false) {
            return res;
        }
        
        if (head->val != tmp->val) {
            return false;
        }
        
        tmp = tmp->next;
        return true;
    }

Log in to reply
 

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