Lecture 81: Linked List LeetCode Problem: Remove Every Kth Node | Rotate List | Palindrome List

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

00:00 Intro
00:37 Problem 1 - Remove Nth Node from END in a Linked List
10:56 Code Part - Remove Nth Node from END in a Linked List
13:54 Solving Run time error
16:50 Problem 2 - Remove Every K Node
29:16 Discussing edge cases
31:16 Code Part - Remove Every K Node
34:48 Problem 3 - Rotate List
55:40 Handling Run Time Error’s and Edge Cases
58:46 Method 2 - Rotate List / Home Work
1:00:22 Problem 4 - Palindrome Linked List
1:77:50 Code Part - Palindrome Linked List
1:24:10 Solving Run Time Error
1:25:51 Outro

Day 116/180, #180daysofcode #180 hard

We are doing 180 days challenge and going to complete the whole course within the duration with quality content on Youtube. I am on the mission to create a tech revolution in our country and in upcoming future we want to create a tech which will create many jobs in India.

Video will come on Mon-Fri at 6am in the morning

DSA Course for free
C++ Free Course
Rohit Negi DSA Course C++
Coder Army DSA Course c++
Function in C++
Pointers in C++.
Strings
Vector
Introduction to Recursion

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

Prabhu Shree Ram ke bhajan ke baad bhaiya ke lectures, best thing in the morning❤

anshuraj
Автор

bhai apke lectures dekh ke to mere jaise gadhe bhi dsa padhne lag jate hain🥺🥺
Thank You bhaiya, apke jaise teacher ki humesha zarurt rehti hai mujhe jo concepts depth mein smjhaye

ritechaserious
Автор

@1:00:07 yes, that method using vectors is also working in the leetcode.👍

ManojSinghRawat-xw
Автор

Small steps lead to big changes. in my coding journey ❤❤ thanks you

universalmeditationmusic
Автор

Now linked list is very easy for me because of you...

arunfrancis
Автор

bhaiya mujhe chamak chuka hai acche se, aaj ki video mei bahut kuch naya sekhne to mila hai!

GitHubNotes
Автор

mzaa aa gya bhaiya linklist mai koi dikkat nhi aa rha ek dum chamak rha h sab

Noobiee_FPS
Автор

Bhaiya aap gazab explain krte ho! Sb samajh aa jaati hai

Saumya_anand
Автор

Small steps lead to big changes. in my coding journey ❤❤ thanks you

GaneshKurhe-nt
Автор

Great teaching skills shown by Rohit bhaiya 🔥🔥🔥🔥🔥

anjalisingh-bxsc
Автор

thank you so much bhaiya
kal bahut tez headache ho rha tha iss wajah se nahi kar paya tha, aaj bhi bahut tez headache ho raha hai but baat consistency ki thi to maine kiya, sach me bahut maza aaya, ab kuchh kuchhh logic soch paa raha hu Linkedlist me.

amankumaramar
Автор

thnkyou sir for this amazing playlist. Thi help me a lot ❤

saurabhnishad
Автор

bhai kya hi phadya h aaj god level boht easily samjh aa gaya thanks sir

tradun.s
Автор

Bhaiya aapne to linked list to khel bana kiya hai thanku so much bhaiya

ravimalviya
Автор

59:43 Home work
bhaiya accept ho gya
CODE

ListNode* rotateRight(ListNode* head, int k) {
// EDGE CASES:
// case 1: empty list ---if(head == NULL)
// case 2: list has only one node ---if(jead->next == NULL)
// case 3: k is zero
if(head == NULL || k==0 || head->next == NULL){
return head;
}
//
// 1: traverse the list and make vector and store each nodes value
// 2: update the nodes value
// a) all the elements of vector from kth position from end
// b) then from begining

ListNode *temp = head;
vector<int> v;
int len=0;
while(temp){
len++;
v.push_back(temp->val);
temp = temp->next;
}
k= k%len;
if(k==0){
return head;
}

temp = head;
for(int i =(len-k); i<v.size(); i++){
temp->val = v[i];
temp = temp->next;
}
for(int i =0; i<(len-k); i++){
temp->val = v[i];
temp = temp->next;
}
return head;
}

mohammadabdullah
Автор

Brute force Linked List Palindrome solution:
class Solution {
public:
bool isPalindrome(ListNode* head) {
//A brute force approach in which we traverse the linked list and store all the values in an array.
ListNode *ptr = head;
vector<int>ans;

while(ptr != NULL){
ans.push_back(ptr->val);
ptr = ptr->next;
}
//By using the two pointer method we compare whether the successive elements are equal or not.
int start =0, end = ans.size()-1;
while(start < end){
if(ans[start] != ans[end]){
return false;
}
else{
start++;
end--;
}
}
return true;

}
};

actualsatan