You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following is the linked list node structure.
template <typename T>
class Node {
public:
T data;
Node* next;
Node(T data) {
next = NULL;
this->data = data;
}
~Node() {
if (next != NULL) {
delete next;
}
}
};
While solving the problem , the code provided in GitHub is not relevant.
#include <bits/stdc++.h>
/************************************************************
************************************************************/
Node* solve(Node* first,Node* second){
Node* curr1=first;
Node* next1=curr1->next;
Node* curr2=second;
Node* next2=curr2->next;
if(next1==NULL){
curr1->next=curr2;
return first;
}
while(next1!=NULL && curr2!=NULL){
if((curr1->data<=curr2->data)&&(next1->data>=curr2->data)){
curr1->next=curr2;
next2=curr2->next;
curr2->next=next1;
// curr2->next=next1;
curr1=curr2;
curr2=next2;
// next2=next2->next;
}
Node* sortTwoLists(Node* first, Node* second)
{
if(first==NULL){
return second;
}
if(second==NULL){
return first;
}
The text was updated successfully, but these errors were encountered: