Copy List with Random Pointer ( with extra space ) | EP 23

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

Crio.Do

Hi, I am Fraz.
I am Software Engineer working at Curefit and I love teaching.
This is my Channel where I upload content related to Interviews and my personal experiences.

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

I watched Striver and many other videos for this but didn't understand. Your explanation for LinkedList videos are really easy to get. Thanks Fraz.

husler
Автор

very easy explanation as compared to other youtubers. thanks

ankitgaur
Автор

Bhaiya aap bhaut accha explain karte ho.Mtlb ek dum basics se explain kiya aapne aur aaram aaram se pura question samjha diya.Superb

RishavRaj-knnm
Автор

I also watched the same problem in other channels but didn't understand a bit.
Here, I found best explanation

pankaj
Автор

Question - accha
Explanation - accha*100
Bhaiya aapka question selection op hai bhut op

desihiphop
Автор

so depth explanation for complex problems ❤️❤️❤️❤️🔥🔥🔥🔥🔥

kalpeshmali
Автор

Perfectly explained sir, I got here after 3 videos and understand this approach here completely .❣️❣️
One suggestion sir, please use relevent tags and #tags in your description so that your videos pop up as when i searched this problem your video doesn't appear .

akhileshkumarmishra
Автор

This series is far better from paid courses, I have seen ❤️

SunnyGupta
Автор

how easily he explained such a difficult question ? Thanks a lot Bhaiya

purushottamkumar
Автор

Suggestion: please use tags like #stack etc... i searched for stack playlist but ur videos didnt show up to me.. its an awesome playlist .. please do this in order to spread this good work

fairyqueen
Автор

1. BRUTE APPROACH(Recursion + HashMap):-

class Solution {
public:
unordered_map<Node*, Node*> m;

Node* dfs(Node* node){
if(!node) return NULL;

if(m.find(node) != m.end()) return m[node];

Node* newNode = new Node(node->val);
m[node] = newNode;

newNode->next = dfs(node->next);
newNode->random = dfs(node->random);
return newNode;
}

Node* copyRandomList(Node* head) {
return dfs(head);
}
};

// Time Complexity = O(n)
// Space Complexity = O(n)


2. OPTIMIZED APPROACH(HashMap) - By Fraz Bhaiya (from this lecture):-

class Solution {
public:
Node* copyRandomList(Node* head) {
unordered_map<Node*, Node*> m;
Node* temp = head;

while(temp != NULL){
Node *copy = new Node(temp->val);
m[temp] = copy;
temp = temp->next;
}

temp = head;
while(temp != NULL){
m[temp]->next = m[temp->next];
m[temp]->random = m[temp->random];
temp = temp->next;
}
return m[head];
}
};

// Time Complexity = O(n)
// Space Complexity = O(n)

Enjoy Guys !!! ❤😉
I wrote here for revision purpose in future but you can use too for revision :)
And Thank to Fraz Bhaiya 🙏🥰❣🔥for whole content :)

Wanna_be_
Автор

sir, please make a video on (computer network) preparation in 3 days for placement
sir, "you forgot it this subject to make a video "
its humble request sir please make a video as soon as possible

HarshRaj-kpgk
Автор

waited for this explanation, thanks bro ❤️

mdsufyankhan
Автор

great explanation bhaiya
I have a little doubt, we are using the map in which we are putting the nodes which are ultimately is going to be part of the answer
then why space complexity is O(N) it should be O(1)

factfactorial
Автор

Bhaiya video is very helpful bhaiya code ke saath comments bhi likh dijiye

mehrasmotivation
Автор

Yaar bhai kisi ka nam to nhi lunga jo flow and sweetness wale mood se aap sikhate hoo sawaal ek point ke baad logic se khud code kr lete h 🤗🤗🤗 pr baad me repent hota h ki phle aapki hi video kyu nhi on ki😓...keep going ....🙏🥺😍

abhayrai
Автор

hey @Fraz Can you pls provide the optimized solution Explanation of count pairs in array whose product is divisible by k? Rather than proving explanation of questions which are already well explained in several other channels.

ankitgarg
Автор

I'm not able to understand how the links have been made?

kritikasharma
Автор

Bhaiya ye sare concepts enough ha interview ke liya ?
In linkedlist topic ?
If some remaining concepts left then please mention

amulop