Reverse Linked List II | Leetcode June Challenge | Leetcode 92 | 2 Approaches + Code | C++ | Hindi

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

Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)

#leetcode
#leetcodeJuneChallenge
#interviewpreparation
Reverse Linked List II solution
Reverse Linked List II Leetcode
Reverse Linked List II C++
Reverse Linked List II C++ Hindi
Reverse Linked List II Hindi

Checkout the series: 🔥🔥🔥
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
Рекомендации по теме
Комментарии
Автор

Whenever I search for a leetcode problem, I always go first for yo ur explanations and if you haven't done that ques yet then move to other video. Best Explanation!!

akshitajha
Автор

I highly appreciate your efforts sister.

mrsmurf
Автор

Thanks for giving this approach
My Solution after getting intuition
class Solution {
private:
ListNode* reverseList(ListNode *head){
if(!head || !head->next)
return head;
ListNode
head->next->next=head;
head->next=NULL;
return reverseHead;
}
public:
ListNode* reverseBetween(ListNode* head, int left, int right) {
//we'll start from first node and check for left
//and right node. After that we'll trim that in-between
//list and reverse it and then join it with rest of
// the list
int count=1;
ListNode *prevNode=NULL, *currNode=head;
while(count!=left){
prevNode=currNode;
currNode=currNode->next;
count++;
}
ListNode* revStart=currNode;
while(count!=right){
currNode=currNode->next;
count++;
}
ListNode * restList=currNode->next;
currNode->next=NULL;
ListNode
count=left;
currNode=reverseHead;
while(count!=right)
{
currNode=currNode->next;
count++;
}
currNode->next=restList;

if(prevNode) prevNode->next=reverseHead;
return prevNode?head:reverseHead;
}
};

Eg- [1, 3, 2, 45, 2, 54, 2, 3, -444, 34, 54, 4, 13, 14, 3]
1
15
In this case we've no prev pointer so we have to return reverseHead only.

harshtyagi
Автор

Wow Thanks but you go in chrome settings and some increase font size before screen recording because when I decrease video quality then video is not clear see

kunalmishra
Автор

Miss you gave me a heart attack I thought my left earbud wasn't working!!! Audio QUALITY !!!

nischayagrawalVlogs
Автор

Please also explain the union of two arrays problem. AND I am learning data structures and algorithms from apna college channel .Can you give me guidance how I prepare for codechef and hackerrank step by step.

filmreviewer
Автор

Theory parts exlelanation is excellent but code part is not sufficient to understood

SouravBag-mx
Автор

u created the dummy node for the case where left=1.

shivprakashgupta
Автор

Great but I am not understand what is the use of dummy node 🙏

mihirsinghsolanki
Автор

how did you make its logic yourself?? i wasted my time making logic but failed

paksharaj
visit shbcf.ru