Find the Intersection point of two Y-shaped LinkedList

Problem Link /* Link list Node struct Node { int data; struct Node* next; }; */ /* Should return data of intersection point of two linked lists head1 and head2. If there is no intersecting point, then return -1. */ int intersectPoint(struct Node* head1, struct Node* head2) { // Your Code Here int cnt1,cnt2,cnt; Node

Merge K sorted LinkedList into one sorted LinkedList

Problem Link /*Linked list node structure struct node { int data; struct node* next; };*/ /*You are required to complete this function*/ node * mergeKList(node *arr[],int N) { //Your code here node *headArray[11]; node *tmpNodes[11]; node *newHead,*tmp,*t; for(int i=0;i<=N;i++) { tmpNodes[i]=arr[i]; } bool f=1; bool first=0; while(f) { int min=10000000; int lastIdx=-1; f=0; for(int i=0;i<=N;i++)

Binary to decimal conversion from a linkedlist binary data stream.

/* Below global variable is declared in code for modulo arithmetic const long long unsigned int MOD = 1000000007; */ /* Link list Node/ struct Node { bool data; // NOTE data is bool struct Node* next; }; */ // Should return decimal equivalent modulo 1000000007 of binary linked list long long unsigned int decimalValue(struct

Some LinkedList Related Problems-2

Reverse A Doubly Linked List. void addNode(struct node **head_ref,int pos,int data) { node *current=*head_ref; while(pos) { current=current->next; pos–; } node *tmp=new node; tmp->data=data; tmp->prev=current; tmp->next=current->next; current->next=tmp; } Prints the nodes having no siblings. /* Tree node structure used in the program struct Node { int data; struct Node* left, *right; }; */ void printSibling(struct Node*

Some LinkedList related problems

Problem Link Sort the linked list according to the actual values: /* The structure of the Linked list Node is as follows: struct Node { Node* next; int data; }; */ void sortList(Node** head) { // Your Code Here Node *tmp=(*head)->next; Node *prevHead; Node *tmp2=new Node; Node *node; bool f=0; while(tmp) { if(tmp->data<0) { if(f==0)

Que Implementation with LinkedList

/* The structure of the node of the queue is struct QueueNode { int data; QueueNode *next; }; and the structure of the class is class Queue { private: QueueNode *front; QueueNode *rear; public : void push(int); int pop(); }; */ /* The method push to push element into the queue*/ void Queue:: push(int x)

Encoding A String function

char *encode(char *src) { //Your code here int length = strlen(src); char *res=(char *)malloc(sizeof(char) * length); int a[5]; int idx=0; int cnt=1,n,pos; res[idx]=src[0]; for(int i=1;i<strlen(src);i++) { if(src[i]!=src[i-1]) { n=cnt; if(n>=10) { pos=-1; while(n) { pos+=1; a[pos]=n%10; n/=10; } while(pos>=0) { idx+=1; res[idx]=char(a[pos–]+'0'); } } else { idx+=1; res[idx]=char(cnt+'0'); } idx+=1; res[idx]=src[i]; cnt=1; } else {