• + 0 comments

    constrain should mention that data would be positive only, or did I just find a bug :P

    int findMergeNode(SinglyLinkedListNode* head1, SinglyLinkedListNode* head2) {
        SinglyLinkedListNode *ptr = head1;
        while (ptr) {
            ptr -> data = -1*(ptr->data);
            ptr = ptr -> next;
        }   
        ptr = head2;
        while (ptr) {
            if(ptr->data<0) return -1*(ptr->data);
            ptr = ptr->next;
        }
        return -1;
    }