Reverse a Linked List | Iterative

preview_player
Показать описание

In case you are thinking to buy courses, please check below:

#dsa #leetcode #placements
Рекомендации по теме
Комментарии
Автор


.
Instagram(connect if you want to know how a SDE's normal life is): @t
.
.
If you appreciate the channel's work, you can join the family: @t

takeUforward
Автор

i tried online articles and famous courses worth 9, 000 to 25, 000. kahi smjh ni aya ki sochna kaise hai, mind mein Linkedlist ke modifications karne kaise hain in c++. but yours' was extraordinary

utkarshsharma
Автор

Nicely explained striver.... You are doing a great job... Keep posting such videos

manishmotwani
Автор

Please make a series on linked lists, like recursion 🙏

krs_rangan
Автор

watched lots of video but this the best one thanks bro

AnandKumar-kzls
Автор

#code in python
class Solution:
# @param A : head node of linked list
# @return the head node in the linked list
def reverseList(self, head):
prev=None
while head:
curr=head
head=head.next
curr.next=prev
prev=curr
return prev

settyruthvik
Автор

Bro just a request, when u will upload cycle detection question please try to explain why floyd detection works because everyone knows the floyd algorithm but the reasoning is still missing.

DeepakGupta-zzvf
Автор

what's is this Listnode *next line? why are we changing the next value and of which node's next is this? it's just simply Linkedlist *next. is next just like a head pointer???

tarunkumar.d
Автор

Very easy explanation !! I ever watched

pruthvirajjadhav
Автор

Hands down Striver, YOU are THE BEST.🙌👏

sharonfaithm
Автор

6:21
newHead=head
Why is this line needed as we have already pointed head.next=newHead
which will store the reference

srinutippana
Автор

Is it important to know both the recursive and iterative method of this question?

zealkapadiya
Автор

Bro can you solve the below problem
There are n robots with intelligence of k for each robot.
Transfer intelligence so that each and every robot has same intelligence i.e. equal intelligence for each robot .But during transfer X% amount of intelligence get loss.
Input format :-
n X
K1 K2 K3 represents
each robot intelligence respectively i.e k intelligence for each robot
Input:-
3 50
1 2 3
Output:-
1.75, 1.75, 1.75

shaiknoor
Автор

Most Optimal Solution:

class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *newHead = NULL;
while(head!=NULL){
ListNode *next = head->next;
head->next = newHead;
newHead = head;
head=next;
}
return newHead;
}
};

jevinmakwana
Автор

We can use recursion. It will be easier.

shlokaggarwal
Автор

understood, thanks for the great explanation

kaichang
Автор

UNDERSTOOD...!!!
Thanks, striver for the video... :)

ranasauravsingh
Автор

why are we creating next node at every iteration, to increase the head pointer we can use head = head.next. but its not working. can anyone explain?

sanukumar
Автор

Awesome bhaiya.... After linked list what topic should I do bhaiya in dsa c++?

adi
Автор

why cant we return head instead of dummy(second last step)?

anonymousaspirant