L22. Rotate a LinkedList

  Рет қаралды 60,026

take U forward

take U forward

Күн бұрын

Problem Link: tinyurl.com/ye...
Entire LL Sheet: takeuforward.o...
Check our A2Z DSA Course: takeuforward.o...
Please do give us a like, and subscribe to us if you are new to our channel.
Do follow us on our socials: linktr.ee/take...

Пікірлер: 115
@sagarchakrabarty7838
@sagarchakrabarty7838 8 ай бұрын
Hi Striver Bhakta!!! I want to convey my heartfelt gratitude for the transformative impact your course has had on my life. Hailing from a village in Assam, where aspirations often go unnoticed, your story and structured content became my guiding light. Today, standing at Deloitte, I owe this achievement to your inspiration and the invaluable A to Z DSA sheet. Thank you for changing lives and paving the way for countless individuals like me. Being a BSc CS grad, I never imagined entering the IT field. I am eagerly looking forward to completing your SDE sheet, anticipating further growth and learning. May your journey be filled with unparalleled success😊.
@priyaaofficial7
@priyaaofficial7 7 ай бұрын
How much LPA have you got?
@albatrossgeez6637
@albatrossgeez6637 6 ай бұрын
@@priyaaofficial7 16
@divyanshinaik190
@divyanshinaik190 Ай бұрын
You make everything seem so easy!
@rushidesai2836
@rushidesai2836 4 ай бұрын
You have made my basics so clear that I was able to come up with a solution without your explanation!
@hat_awesome21
@hat_awesome21 9 ай бұрын
U r literally helping lots of students , thanks a lot
@kingstock5654
@kingstock5654 9 ай бұрын
Striver ig these are few remaining probs • Clone a Linked List with random and next pointer • flattening of LL • sort a LL
@takeUforward
@takeUforward 9 ай бұрын
Yes will upload in 3/4 days.
@ganjinaveen7338
@ganjinaveen7338 9 ай бұрын
@@takeUforward please upload remaining videos striver sir
@keerthanpailwan6477
@keerthanpailwan6477 9 ай бұрын
striver please upload next videos@@takeUforward
@TheSpiritualOne401
@TheSpiritualOne401 9 ай бұрын
please upload sir @@takeUforward
@takeUforward
@takeUforward 9 ай бұрын
Yes I will, thoda sa I am an road, will do it. @@TheSpiritualOne401
@manjunathadharagond9322
@manjunathadharagond9322 9 ай бұрын
God of DSA TUTORIALS🔥
@harshitgarg2820
@harshitgarg2820 9 ай бұрын
Completed all the given videos and their corresponding questions. I'm eagerly waiting for the remaining videos🚀🚀
@Movies-7914
@Movies-7914 8 ай бұрын
how many are remaining?
@harshitgarg2820
@harshitgarg2820 8 ай бұрын
@@Movies-7914 three
@hat_awesome21
@hat_awesome21 9 ай бұрын
bhaiya plz upload stack and queue , placements are coming
@shubhamkumar-hx1fb
@shubhamkumar-hx1fb 9 ай бұрын
Ur semester pls?
@AryanKumar-ji6mb
@AryanKumar-ji6mb 8 ай бұрын
i would urge bhaiya to complete all the pending topics asap
@nithishkumarsaravanan969
@nithishkumarsaravanan969 5 ай бұрын
Look at his eyes! says his dedication
@amankira2333
@amankira2333 7 ай бұрын
Bro hattsoff!! now i am feeling confident in linked list topic. thanks
@zyzzbrah9429
@zyzzbrah9429 9 ай бұрын
bro stacks,queues,bits,strings upload karo bhai please
@user-gk4zy6bk7l
@user-gk4zy6bk7l 9 ай бұрын
Bhaiya string aur bit manipulation bhi la do🥺🥺
@manjunathadharagond9322
@manjunathadharagond9322 9 ай бұрын
Striver community ❤
@keshabkrishnadas4674
@keshabkrishnadas4674 7 ай бұрын
Done and Dusted ✅✅😎
@naamhaii
@naamhaii 9 ай бұрын
Stack and queue playlist please
@Akhillbj
@Akhillbj 9 ай бұрын
Ruk ja, bhai woh bhi toh insaan hi hai! Till then why not read more about those things and understand them how much ever you can
@naamhaii
@naamhaii 9 ай бұрын
@@Akhillbj ☪️🔫
@bruvhellnah
@bruvhellnah 9 ай бұрын
@@Akhillbj Ignore these clowns lol. They go on demanding on every video without ever putting any efforts of their own lol
@Akhillbj
@Akhillbj 9 ай бұрын
@@bruvhellnah some one has to start somewhere, chill karo bhai
@mbm.editzz
@mbm.editzz 9 ай бұрын
@@bruvhellnah atleast he's requesting politely totally uncalled for to call him a clown
@csea_37_shayoribhowmick53
@csea_37_shayoribhowmick53 5 ай бұрын
I have done this problem thank you Striver ❤
@varunpalsingh3822
@varunpalsingh3822 9 ай бұрын
Thank you striver, understood ❤
@PivotGamer
@PivotGamer 9 ай бұрын
Im learning from you, Strings playlist when 😁
@codeguy21
@codeguy21 9 ай бұрын
bhai next stack and queue plz
@sakshijain8549
@sakshijain8549 8 ай бұрын
Bhaiya!! DSA AtoZ playlist is not working, I follow only your playlist to study, your playlist was so helpful.Please make it available again...
@nikunjkhakhkhar1030
@nikunjkhakhkhar1030 6 ай бұрын
Can we use the same logic as you shown in previous video, remove kth node from end of linked list, from that video we can use the part where we maintain distance between fast and slow, then in single pass only we will be able to do this, and no need to compute length. By the way you are doing great work 😊
@jk-sj4nf
@jk-sj4nf 9 ай бұрын
hey striver , can we expect stack & queue as next plz
@gauravbairagi209
@gauravbairagi209 9 ай бұрын
great video
@himanshuyadav0600
@himanshuyadav0600 9 ай бұрын
Next Stack , Queue, Strings playlist sir please..
@user-go9vs3vm5d
@user-go9vs3vm5d 4 ай бұрын
solved on my own credit goes to you really helpful .....
@lucifersamrat6280
@lucifersamrat6280 Ай бұрын
god level explanation bhai
@nileshk19
@nileshk19 8 ай бұрын
Thank You Striver❣. Understood.
@namannema3349
@namannema3349 9 ай бұрын
hey i dont have intrest in reading the article to see the solution but striver bhaiya has told first to see article and then video i love to understand from video only what should i do @take U forward
@dorothybhowmicktopic6889
@dorothybhowmicktopic6889 6 ай бұрын
Amazingggggg🎉
@Irritate-lu1bt
@Irritate-lu1bt 8 ай бұрын
one more subscriber ..hats off
@techtuber1344
@techtuber1344 6 ай бұрын
Finally did que myself, //function to find Lenth of LL : 0(N) int lenOfList(ListNode* head){ ListNode* temp = head; int cnt = 0; while(temp != nullptr){ cnt++; temp = temp->next; } return cnt; } //function to rotate ListNode* rotateRight(ListNode* head, int k) { //corner case , if head is null do nothing and if only one element how many times u may rotate itself is head, if(head == nullptr || head->next == nullptr) return head; //Finding Length int len = lenOfList( head); //if k>N bounding k k = k % len; //slow and fast pointers ListNode* fast = head; ListNode* slow = head; //moving fast ptr till k so that next traverse slow will at one step behind rotation pt and fast at last node for( int i = 1 ; inext; } //now fast node is at last and slow is rotation pt while(fast!= nullptr && fast->next != nullptr){ //O(1/2N) total 2N and no space used; slow = slow->next; fast = fast->next; } //if fast not null then only its next is head , for linking i did this if(fast!= nullptr)fast->next = head; //new head for rotated list head = slow->next; slow->next = nullptr;//unlink return head; }
@kushagrasharma2738
@kushagrasharma2738 8 ай бұрын
Why are you not uploading your course videos with consistency sir😅?? We wanna make this AtoZ sheet course best DSA course ever.. but it needs videos consistency.. when all video solution of your sheet questions will be available.. it becomes a best best best DSA course 🔥. Please bhaiya complete this 😊❤️.. i hope with new year you upload strings..stack..queue..bits questions solutions.
@GagandeepSingh-cp1pe
@GagandeepSingh-cp1pe 9 ай бұрын
complete the playlist soon ✨
@saikumargatla4706
@saikumargatla4706 9 ай бұрын
Next series on recursion.Like if if you want next series on recursion
@AmanSharma-xy1qm
@AmanSharma-xy1qm 8 ай бұрын
Bhaiya website ke articles unreachable bta rhe hai, kb tk back hogi website??
@YourCodeVerse
@YourCodeVerse 7 ай бұрын
Understood✅🔥🔥
@Oldmonk3321
@Oldmonk3321 4 ай бұрын
Yes bhai please upload stack abd queues 😢
@himanshidafouty347
@himanshidafouty347 2 ай бұрын
Understood
@helloworld2054
@helloworld2054 9 ай бұрын
Your eyes 😧
@ganeshvhatkar9253
@ganeshvhatkar9253 7 ай бұрын
Understood Sir, i had done by dummy node concept then after I deleted it. Node *rotate(Node *head, int k) { Node* temp=head; int len=0; Node* prevnode=NULL; Node* tail=NULL; while(temp!=NULL){ len++; if(temp->next==NULL){ tail=temp; } temp=temp->next; } temp=head; if(k>len) k=k%len; int reach=len-k; if(reach==len || reach==0){ return head; } while(reach!=0){ reach--; prevnode=temp; temp=temp->next; } Node* dummynode=new Node(-1); Node* current=dummynode; current->next=temp; tail->next=head; prevnode->next=NULL; Node* newhead= dummynode->next; free(dummynode); return newhead;
@hardikpatel352
@hardikpatel352 3 ай бұрын
understood
@noobyerror7815
@noobyerror7815 3 ай бұрын
just adding a extension (correct me if i am wrong) roate the linked list in ANTI-CLOCKWISE direction. . . . , . .. . . . . . .
@aryasharma69
@aryasharma69 5 күн бұрын
ENJOY public static Node rotateLeft(Node head, int k) { if (head == null || head.next == null || k == 0) { return head; } Node temp = head; int length = 1; while (temp.next != null) { temp = temp.next; length++; } k = k % length; if (k == 0) { return head; } Node current = head; for (int i = 1; i < k; i++) { current = current.next; } Node newHead = current.next; current.next = null; temp.next = head; return newHead; }
@anshror2583
@anshror2583 8 ай бұрын
Bhai next playlist greedy please
@user-tk2vg5jt3l
@user-tk2vg5jt3l 6 ай бұрын
Thank you Bhaiya
@user-go9vs3vm5d
@user-go9vs3vm5d 4 ай бұрын
i am already practising dsa from many days but starting day1 of my dsa for tracking
@nileshbahetwar2816
@nileshbahetwar2816 8 ай бұрын
Sir sde sheet who knows DSA is working fine but why a2z sde sheet showing "file not found error"? Are you updating the sheet?
@bishalkundu7592
@bishalkundu7592 9 ай бұрын
Understood ❤
@NARUTOUZUMAKI-bk4nx
@NARUTOUZUMAKI-bk4nx 7 ай бұрын
Understooood
@MJBZG
@MJBZG Ай бұрын
could write it on my own
@aplakusattakharyab
@aplakusattakharyab 8 ай бұрын
guys website is down
@nehapimpalkar396
@nehapimpalkar396 7 ай бұрын
understood!
@johnyjangid8541
@johnyjangid8541 9 ай бұрын
Ok someone please reply How to watch Stirver's DSA Tutorials like:- Array, Now how to watch it I mean Do i have to write the code in my copy, Or code along with Striver Please someone tell me the best way😢😢
@vaibhavvm4147
@vaibhavvm4147 9 ай бұрын
same q
@johnyjangid8541
@johnyjangid8541 9 ай бұрын
@@vaibhavvm4147 Please reply anybody
@AdityaGarg-hl7ri
@AdityaGarg-hl7ri 9 ай бұрын
Bro code kro and keep the codes with comments with you
@johnyjangid8541
@johnyjangid8541 9 ай бұрын
@@AdityaGarg-hl7ri Bro to matlab notes Cause I am an absolute Newbie Who doesn't know anything about DSA
@AdityaGarg-hl7ri
@AdityaGarg-hl7ri 9 ай бұрын
i will suggest watch each video twice , first try to understand and code in vs code or any problem solving site then watch it again and make notes by your own understanding of the concept
@dayashankarlakhotia4943
@dayashankarlakhotia4943 9 ай бұрын
Your code TLE in gfg?
@Hemanthkumar-ck1zu
@Hemanthkumar-ck1zu 8 ай бұрын
The dsa a2z sheet and the 79 sheet is not accessible Can you please look into this Thankyou.
@gauravbairagi209
@gauravbairagi209 9 ай бұрын
1st comment
@user-hl1go9pb9u
@user-hl1go9pb9u 9 ай бұрын
striver i practicing in this A2Z sheet but its not loading from yesterday kindly someone please inform what to do
@vigneshmohankumar3388
@vigneshmohankumar3388 8 ай бұрын
What happened to the website, we r getting 503 service unreachable error. Please resolve it.
@likhithalikhitha-rs1ry
@likhithalikhitha-rs1ry 8 ай бұрын
take u forward website is not working and is showing file not found everywhere it would become very hard for us without that sheet please look into this i cant find any help line so i commented hope it would be visible and action will be taken...I'll be very thankful if it gets checked and i love the content and course provided by you
@printfiamd5254
@printfiamd5254 9 ай бұрын
What about this approach??? int lengthOfLL(Node *head) { int cnt = 0; while (head != NULL) { ++cnt; head = head->next; } return cnt; } Node *rotateKTimes(Node *head, int k) { if (head == NULL || head->next == NULL) return head; int l = lengthOfLL(head); for (int i = 0; i < k % l; i++) { Node *temp = head; while (temp->next->next != NULL) { temp = temp->next; } Node *newNode = temp->next; temp->next = NULL; newNode->next = head; head = newNode; } return head; }
@jritzeku
@jritzeku 4 ай бұрын
Is there link to this code solution plus diagrams? I recall seeing them in descriptions during your Trees playlist but not finding in LinkList section.
@State_exam_preparation
@State_exam_preparation 9 ай бұрын
QUESTION! Is it possible to get element before kth node if head is pointing to kth node??singly ll
@kushagrasahay
@kushagrasahay 8 ай бұрын
you can take a dummy node and while traversing LL with head assign head to dummy. In this way when you reach kth node you will have a dummy pointing to (k-1)th
@State_exam_preparation
@State_exam_preparation 8 ай бұрын
@@kushagrasahay you can't traverse,that's the catch only.
@kushagrasahay
@kushagrasahay 8 ай бұрын
@@State_exam_preparation there is no way to stay on a node and reach its previous and linked lists are complelety based on linear traversals.
@kushagrasahay
@kushagrasahay 8 ай бұрын
that is possible in case of doubly LL
@kushagrasahay
@kushagrasahay 8 ай бұрын
@@State_exam_preparation moreover, we are not having any extra traversals. The traversal in which you go till kth node. In that only you get the previous one. Just taking an extra pointer
@buvaneswari8461
@buvaneswari8461 7 ай бұрын
Yeah done and dusted
@sayalihere-sm3yx
@sayalihere-sm3yx 8 ай бұрын
please complete string and rest ,as u get time 😅
@rajvardhan465
@rajvardhan465 9 ай бұрын
Sorry aak like this this is in java dsa or python or Both concepts are same please explain sir
@user-gk4zy6bk7l
@user-gk4zy6bk7l 4 ай бұрын
god
@Saloni-gr1gq
@Saloni-gr1gq 8 ай бұрын
Why the course sheet is not opening please do something
@corporateAniruddha
@corporateAniruddha 8 ай бұрын
Vaiya baki videos kab tak ayenga
@ak27129
@ak27129 8 ай бұрын
is this series completed now?
@jyothiyadav2595
@jyothiyadav2595 3 ай бұрын
def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ def reversell(node): if node.next: return node newnode=reversell(node.next) front=node.next front.next=node node.next=None return newnode temp,count=head,0 while temp: count+=1 temp=temp.next k=k%count index=count-k slow=head for i in range(1,index): slow=slow.next nextnode=slow.next print(nextnode.val) if nextnode==None: return head slow.next=None firstpart=reversell(head) print("first") lastpart=reversell(nextnode) print("next") head.next=lastpart head=reversell(firstpart) print("last") return head can someone tell me why is this not working??
@japleencrafts4690
@japleencrafts4690 8 ай бұрын
Ghatiya video... Bhaisaab ki awaaz itni acchiii h ki mujhe need nhi a pa rhiiii bhyiiiii... Bs krooooooo😢😢😢
@zyzzbrah9429
@zyzzbrah9429 9 ай бұрын
bro stacks,queues,bits,strings upload karo bhai please
@dewanandkumar8589
@dewanandkumar8589 3 ай бұрын
Understood
@Shivi32590
@Shivi32590 Ай бұрын
understood
@zyzzbrah9429
@zyzzbrah9429 9 ай бұрын
bro stacks,queues,bits,strings upload karo bhai please
@zyzzbrah9429
@zyzzbrah9429 9 ай бұрын
bro stacks,queues,bits,strings upload karo bhai please
@zyzzbrah9429
@zyzzbrah9429 9 ай бұрын
bro stacks,queues,bits,strings upload karo bhai please
@harshitpatil6138
@harshitpatil6138 7 ай бұрын
understood
@aasimahsan6167
@aasimahsan6167 9 ай бұрын
understood
L23. Merge two sorted Linked Lists
18:55
take U forward
Рет қаралды 55 М.
Violet Beauregarde Doll🫐
00:58
PIRANKA
Рет қаралды 50 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 48 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 86 МЛН
L21. Reverse Nodes in K Group Size of LinkedList
24:31
take U forward
Рет қаралды 82 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 204 М.
L9. Reverse a LinkedList | Iterative and Recursive
32:42
take U forward
Рет қаралды 127 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 348 М.
Rotate List - Linked List - Leetcode 61 - Python
10:16
NeetCode
Рет қаралды 41 М.
L14. Detect a loop or cycle in LinkedList | With proof and Intuition
20:26
Violet Beauregarde Doll🫐
00:58
PIRANKA
Рет қаралды 50 МЛН