ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
Best concepts 🎉❤❤❤❤
Glad you like it 😊✨😊
class Solution { public: Node* sortedInsert(Node* head, int x) { // Code here Node* curr = head,* nxt = head->next; Node* node = getNode(x); if(!head->next){ if(head->data next = node; node->prev = head; return head; } node->next= head; head ->prev = node; return node; } if(head->data> x){ node->next = head; head -> prev = node; head = node; return head; } while(x>nxt->data && nxt){ curr = nxt; nxt = nxt->next; if(!nxt) break; } if(!nxt){ curr->next = node; node->prev = curr; return head; } curr->next = node; node->prev = curr; node->next= nxt; nxt -> prev = node; return head; }};
Best concepts 🎉❤❤❤❤
Glad you like it 😊✨😊
class Solution {
public:
Node* sortedInsert(Node* head, int x) {
// Code here
Node* curr = head,* nxt = head->next;
Node* node = getNode(x);
if(!head->next){
if(head->data next = node;
node->prev = head;
return head;
}
node->next= head;
head ->prev = node;
return node;
}
if(head->data> x){
node->next = head;
head -> prev = node;
head = node;
return head;
}
while(x>nxt->data && nxt){
curr = nxt;
nxt = nxt->next;
if(!nxt) break;
}
if(!nxt){
curr->next = node;
node->prev = curr;
return head;
}
curr->next = node;
node->prev = curr;
node->next= nxt;
nxt -> prev = node;
return head;
}
};