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

แชร์
ฝัง
  • เผยแพร่เมื่อ 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;
    }