XOR Linked List | GFG Problem of the Day | Linked List

Поделиться
HTML-код
  • Опубликовано: 7 окт 2024

Комментарии • 1

  • @codetips-byRochak
    @codetips-byRochak  День назад

    Let's Connect 🤝 :
    LinkedIn : www.linkedin.com/in/rochak-vyas17/
    Code :-
    struct Node *insert(struct Node *head, int data) {
    Node* newnode=new Node(data);
    newnode->npx=XOR(NULL,head);
    if(head!=NULL){
    Node* temp=XOR(head->npx,NULL);
    head->npx=XOR(temp,newnode);
    }
    head=newnode;
    return head;
    }
    vector getList(struct Node *head) {
    vectorans;
    Node* prev=NULL;
    while(head!=NULL){
    ans.push_back(head->data);
    Node* temp=head;
    head=XOR(prev,head->npx);
    prev=temp;
    }
    return ans;
    }