Weird error JSON


  • 0
    J

    Any ideas on this: Expected JSON [8,25,19,19,28,38,45,44,25,37,43,36,39,27,28,3,42,5,21,19,33,12,2,18,12,44]] to be of type JSMN_ARRAY but got JSMN_PRIMITIVE.

    /**
     * Definition for singly-linked list.
     * struct ListNode {
     *     int val;
     *     ListNode *next;
     *     ListNode(int x) : val(x), next(NULL) {}
     * };
     */
    class Solution {
        void inp(){
            std::ios::sync_with_stdio(false);
            cin.tie(NULL);
            done=true;
        }
        bool done=false;
    public:
        ListNode* removeNthFromEnd(ListNode* head, int n) {
            if(!done) inp();
            int c=0,i=0;
            ListNode* node = head;
            vector<ListNode*> id;
            while(node){
                id.push_back(node);
                c++;
                node=node->next;
            }
            if(c==n) return head->next;
            id.push_back(NULL);
            id[c-n-1]->next=id[c-n+1];
            return head;
        }
    };
    

Log in to reply
 

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