Тёмный

Delete nodes which have a greater value on right side | LinkedList | GFG | Love Babbar DSA Sheet🔥🔥 

Yogesh & Shailesh (CodeLibrary)
Подписаться 51 тыс.
Просмотров 22 тыс.
50% 1

#Linkedlist #competitiveprogramming #coding #dsa
Hey, Guys in this video I have explained with code how we can solve the problem 'Delete nodes which have a greater value on right side '.
Join our Telegram Channel for more Information
🔰 Telegram Channel Link = t.me/CodeLibrary1
🔰 Get 10% OFF on all GeeksforGeeks Courses
Coupon Code = CODELIBRARY
🔰 Array Playlist = • Love Babbar DSA 450 Qu...
🔰 String Playlist = • Love Babbar DSA 450 Qu...
🔰 Searching and Sorting Playlist = • Love Babbar DSA 450 Qu...
🔰 Binary Tree Playlist = • Love Babbar DSA 450 Qu...
🔰 Linked List Playlist = • Love Babbar DSA 450 Qu...
🔰 Graph Playlist = • Love Babbar DSA 450 Qu...
🔰 Dynamic Programming Playlist = • Love Babbar DSA 450 Qu...
🔰 Informative Videos = • Informative Videos
🔰 Love Babbar DSA Sheet: drive.google.com/file/d/1FMdN...
Follow us on Instagram:
🔰 Shailesh Yogendra : / shaileshyogendra
🔰 Yogesh Yogendra : / i_am_yogesh_here
Follow us on LinkedIn:
🔰 Yogesh Yogendra : / yogesh-yogendra-26bbb518a
🔰 Shailesh Yogendra : / shailesh-yogendra-8b13...
Hope you like it. Comment if you have any doubt
LIKE | SHARE | SUBSCRIBE

Опубликовано:

 

17 апр 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@nandiniagarwal9116
@nandiniagarwal9116 Год назад
Amazing bhaiya ....... Aise hi aap questions practice karate rahiye bhot helpful hai
@sahasransupanda8169
@sahasransupanda8169 3 года назад
What will happen if we use three pointers and start traversing from left without reversing the linkedlist ...what will be the time complexity??
@kushkumar9936
@kushkumar9936 3 года назад
your videos is very helpful
@_hulk748
@_hulk748 Год назад
Thankyou sir❤🙇‍♂🙏
@ashvinimeshram5242
@ashvinimeshram5242 3 года назад
Nice explaination
@sumedhdvs8739
@sumedhdvs8739 3 года назад
good explanation bro
@sanathbhardwaj919
@sanathbhardwaj919 3 года назад
Best explanation
@adityapandey8245
@adityapandey8245 3 года назад
Thanks vro
@1piecegaming622
@1piecegaming622 3 года назад
next question clone a linked list with random and next pointer please
@vashishthsharma4411
@vashishthsharma4411 Год назад
thank you bhai
@bihariboyzyt826
@bihariboyzyt826 3 года назад
Op
@MohammadImran-bb7sj
@MohammadImran-bb7sj Год назад
I think, we can do this problem without reversing the linked list. Right?
@pinkkitty6553
@pinkkitty6553 11 месяцев назад
Thabks
@jayeshnayee6735
@jayeshnayee6735 2 года назад
How to solve Using recursion???
@anjandey6089
@anjandey6089 3 года назад
BST ka upr video bana do vai
@govinds8745
@govinds8745 Год назад
Bhai, node delete karne ka invitation du kya. Worst case ke hisab se memory leak ki problem hogi
@rishavraj9284
@rishavraj9284 5 месяцев назад
Ye chutiye log code ko rat lete hai isiliye delete nhi kiya😅 memory leak hone se iska code baccha lega
@shubhenducomic352
@shubhenducomic352 2 года назад
code ka link bhejdo plz
@rohitchilhorkar8114
@rohitchilhorkar8114 2 года назад
Can you tell me why this code is giving TLE. Node *compute(Node *head) { // your code goes here while(head->data < head->next->data && head->next!=NULL) head = head->next; struct Node* prev = head; if(head->next == NULL) return head;//as in 10 20 30.. struct Node* mid = head->next; struct Node* last = head->next->next; while(last!=NULL) { if(mid->data < last->data && last->next == NULL) prev->next = last; else if(mid->data < last->data) { mid = mid->next; last = last->next; } if(mid->data >= last->data) { prev->next = mid; prev = mid; mid = mid->next; last = last->next; } } prev->next = NULL; return head; }
@SurajChoubeyoppa
@SurajChoubeyoppa 2 года назад
Short and fast solution: class Solution { public: Node *compute(Node *head) { if(head == NULL || head -> next == NULL) return head; head -> next = compute(head->next); if(head -> next -> data > head -> data) return head -> next; return head; } };
@debasishphukon5345
@debasishphukon5345 2 года назад
Nice solution re :D
@rahulsaini2084
@rahulsaini2084 2 года назад
Ya bro no doubt short solution but it's depend on conditions as you use recursion so tha space complexity will be o(n) .
@priyanshusingh2454
@priyanshusingh2454 2 года назад
Node* fun(Node* head, int &mx) { if(head->next == NULL) { mx = head->data; return head; } head->next = fun(head->next, mx); if(head->data >= mx) { mx = head->data; return head; } return head->next; } Node *compute(Node *head) { int mx = 0; return fun(head, mx); }
@akshaysuryavanshi9420
@akshaysuryavanshi9420 8 месяцев назад
if(second!=NULL){ second= second->next; }. second is the pointer for head's next element. Put this condition in ur reverse function.
@prasannapm3220
@prasannapm3220 2 года назад
good
@anubhabray5254
@anubhabray5254 3 года назад
I have done it using brute force approach but got TLE for the same: Node* deleteNode(Node **head,int x) { if(x==1){ Node* temp = *head; if(temp->next==NULL){ free(*head); return NULL; } *head=temp->next; free(temp); return *head; } int i=1; Node* temp = *head; while(inext; i++; } Node* nextnode=temp->next; temp->next=nextnode->next; free(nextnode); return *head; } Node *compute(Node *head) { Node* temp=head; vector v; int pos=0; while(temp->next!=NULL){ pos++; Node* check=temp->next; while(check!=NULL){ if(check->data>temp->data){ v.push_back(pos); break; } check=check->next; } temp=temp->next; } while(v.size()>0){ int x = v.back(); v.pop_back(); head = deleteNode(&head,x); } return head; }
@Man_of_Culture.
@Man_of_Culture. 3 года назад
bro I have solved this problem without reversing the list Node *compute(Node *head) { Node *c=head,*n=NULL,*p=NULL; c=head; int i,flag=0; while(c) { i=0; if(c->next) { n=c->next; if(c->datadata) { if(c==head) { head=n; free(c); c=n; i=1; } else { p->next=n; free(c); c=n; i=1; } flag=1; } } if(i==0) { p=c; c=c->next; } if(!c and flag==1) { c=head; flag=0; } else if(!c and flag==0) break; } return(head); }
@justarandomguy6106
@justarandomguy6106 2 года назад
Bro ur code is so complicated, atleast explain it
@Man_of_Culture.
@Man_of_Culture. 2 года назад
@@justarandomguy6106 bhai ab to mai bhul gya ki mene Kara kya hai isme Mai khud dar gya ye code mene hi likha hai 🤣🤣
@justarandomguy6106
@justarandomguy6106 2 года назад
@@Man_of_Culture. true🤣🤣🤣, lekin kya work kra tha??
@Man_of_Culture.
@Man_of_Culture. 2 года назад
@@justarandomguy6106 kar hoga tabhi post kiya hoga ,Chala ke dekh lo fir mujhe bhi batao🤣
@justarandomguy6106
@justarandomguy6106 2 года назад
@@Man_of_Culture. konsa college and year me ho aap
@himanshukumaramb1184
@himanshukumaramb1184 2 года назад
aarey kyaaa hi video banate hoo , saara system hill jata hai , bawaaal
Далее
This Stop Motion is Insane
00:39
Просмотров 7 млн
L26. Sort a Linked List | Merge Sort and Brute Force
22:11
L6. Odd Even Linked List | Multiple Approaches
24:05
Просмотров 67 тыс.