wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
Sir, I really don't know why your channel is quite underrated maybe the reach is low but, let me tell you this thing if anyone sees ur videos I am damn sure he/she will surely subscribe and will thank you for ur such a wonderful effort. I have really become a "JABRA FAN" of urs. Sir, please never feel disheartened due to ur channel growth I deeply pray for ur channel growth and you a fabulous life. I really really love u and ur teaching💖💖💖.
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
Thankyou beta, If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
So nice of you and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
So nice of you and If you like the content could you post something on LinkedIn about us? This will help us in reaching out to more people and help a lot of other students as well Something like this Sumeet Malik from Pepcoding is making all his content freely available to the community You can check it out here - www.pepcoding.com/resources / Also, this is the youtube channel - th-cam.com/users/Pepcodingplaylists?view_as=subscriber
sir your videos are just too amazing. Sir trees ke kuch questions mein agar logic samjh aata hai ki kaise solve karna hai toh recursive code likhna samjh nhi aata. Abhi tak I have solved all the basic level wale and kuch jo bfs se solve hopaate hai wo kiye but dfs approach mein dikkat aari hai. Pls help sir
aap ek baar yahan se is order me questions solve kijie (www.pepcoding.com/resources/online-java-foundation) 1. Recursion 2. Generic Trees 3. Binary Trees Isse improve nahi hua to I will give you more questions
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. If you like our efforts, we request a review g.page/Pepcoding/review?rc You can subscribe to our channel here th-cam.com/users/Pepcodingabout?view_as=subscriber
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
Thankyou beta! I am glad you liked it. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms ) Keep learning and keep supporting Pepcoding🙏
Thankyou beta! I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
parent nahi, par isko travel karke harek ke neighbors ko dekh ke graph mei convert kar lo aur target node se bfs chla do. great observation. bhot mza aya.
is type ke aur sawaal levelup and IP mein aayenge naa- for ex- www.geeksforgeeks.org/minimum-time-to-burn-a-tree-starting-from-a-leaf-node/?ref=rp www.geeksforgeeks.org/burn-the-binary-tree-starting-from-the-target-node/
I don't know why, but you are just awesome! Whenever I am struck with a hard problem and can't solve it anyways, you are the help.
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
The clarity of your concepts ! Hats Off Sir 🙌👌
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
Sir, I really don't know why your channel is quite underrated maybe the reach is low but, let me tell you this thing if anyone sees ur videos I am damn sure he/she will surely subscribe and will thank you for ur such a wonderful effort. I have really become a "JABRA FAN" of urs.
Sir, please never feel disheartened due to ur channel growth I deeply pray for ur channel growth and you a fabulous life.
I really really love u and ur teaching💖💖💖.
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
Can u tell the time complexity of this?
The explanation for any problem and ways to tackle them are just the best
I really like your explanations, you do nothing fancy and explain the concept with simplicity.
Glad you think so!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
kaafi shandaar sawaal aur kaafi shandaar explanation :)
Thankyou beta,
If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
@@Pepcoding sure sir
Mja aa gya sir.... You just make things simple😀😀
Sir i am fan after seeing this solution the way you explain sir awesome luv u
So nice of you and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
As always great content , explanation in depth.... thanks sir!!!!
So nice of you and If you like the content could you post something on LinkedIn about us? This will help us in reaching out to more people and help a lot of other students as well
Something like this
Sumeet Malik from Pepcoding is making all his content freely available to the community
You can check it out here - www.pepcoding.com/resources
/
Also, this is the youtube channel - th-cam.com/users/Pepcodingplaylists?view_as=subscriber
sir your videos are just too amazing. Sir trees ke kuch questions mein agar logic samjh aata hai ki kaise solve karna hai toh recursive code likhna samjh nhi aata. Abhi tak I have solved all the basic level wale and kuch jo bfs se solve hopaate hai wo kiye but dfs approach mein dikkat aari hai. Pls help sir
aap ek baar yahan se is order me questions solve kijie (www.pepcoding.com/resources/online-java-foundation)
1. Recursion
2. Generic Trees
3. Binary Trees
Isse improve nahi hua to I will give you more questions
the path is a list of integer then how you are passing it to print k level down where the argument is Node
Hats off SIr!
Some time I fell @Sumeet Sir is GOD...How he make all this thing like water ??
Sir, what is the time complexity of this code?
Strulling a lot sir thanks sir this is the best explanation☺
crystal clear explanation!! Thanks ...!
can u tell the time complexity of this?
@@ita501aryanagrawal4 O(N)
No challenge to you sir!!
Shrewdness next level!!
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
@@Pepcoding Sure.
Soo good, I loved it.....
sir what is the time complexity of this??
Very good question sir .thanku
i did it after the nodeToRootPath hint :)
//c++ code by me
vector nodeToRootNodes(Node* root, int val) {
if(root == NULL) {
return vector();
}
if(root->data == val) {
return vector(1, root);
}
if(root->left) {
vector ntrLeft = nodeToRootNodes(root->left, val);
if(!ntrLeft.empty()) {
ntrLeft.push_back(root);
return ntrLeft;
}
}
if(root->right) {
vector ntrRight = nodeToRootNodes(root->right, val);
if(!ntrRight.empty()) {
ntrRight.push_back(root);
return ntrRight;
}
}
return vector();
}
void printLevelK2(Node* root, int k, Node* node) {
if(root == NULL || k < 0 || root == node) return;
if(k == 0) {
cout data left, k-1, node);
printLevelK2(root->right, k-1, node);
}
void pritnNodesKDistanceAway(Node* root, int val, int k) {
vector ntr = nodeToRootNodes(root, val);
for(int i = 0; i < ntr.size() && k >=0; i++,k--) {
printLevelK2(ntr[i], k, (i == 0) ? NULL : ntr[i-1]);
}
}
Thank you sir that was so easy to understand
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
what is the time complexity of this solution?
Aag lga di sirji
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
If you like our efforts, we request a review
g.page/Pepcoding/review?rc
You can subscribe to our channel here
th-cam.com/users/Pepcodingabout?view_as=subscriber
U are just amazing
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
Wonderful explaination sir🔥
Thankyou beta!
I am glad you liked it. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
Keep learning and keep supporting Pepcoding🙏
Can u tell the time complexity?
Amazing explanation!
Thankyou beta!
I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
Great Explanation 🙌
Glad it was helpful!
Very nicely explained ^ ^
Sir isko parent of har element nikalke bfs se bi krskte hai na?
parent nahi, par isko travel karke harek ke neighbors ko dekh ke graph mei convert kar lo aur target node se bfs chla do. great observation. bhot mza aya.
Brilliant !
keep motivating, keep learning and keep loving Pepcoding😊
Who done this question first time in interview
Please anyone can tell what is the time complexity seems like greater than N
O(N) hai beta
7:08 👀
Iska time complexity kya hoga koi bata sakta hai
All yours doubts will be cleared on nados.pepcoding.com
Also don't forget to follow our Instagram account.
is type ke aur sawaal levelup and IP mein aayenge naa- for ex-
www.geeksforgeeks.org/minimum-time-to-burn-a-tree-starting-from-a-leaf-node/?ref=rp
www.geeksforgeeks.org/burn-the-binary-tree-starting-from-the-target-node/
Bilkul aaenge.
Ip?
why is every video repeated
question video and solution video are separate. watch the question video, attempt it, then watch the solution video.
public static class Pair {
Node node;
int state;
Pair(Node node, int state) {
this.state = state;
this.node = node;
}
}
public static ArrayList Node2RootPath(Node root, int x) {
if (root == null) {
return new ArrayList();
}
if (root.data == x) {
ArrayList ans = new ArrayList();
ans.add(root);
return ans;
}
ArrayList lans = Node2RootPath(root.left, x);
if (lans.size() > 0) {
lans.add(root);
return lans;
}
ArrayList rans = Node2RootPath(root.right, x);
if (rans.size() > 0) {
rans.add(root);
return rans;
}
return new ArrayList();
}
public static void kLevelDown(Node root, int k, Node block) {
if (root == null || k < 0 || root == block) {
return;
}
Queue st = new ArrayDeque();
st.add(new Pair(root, 0));
if (k == 0) {
System.out.println(root.data);
return;
}
while (!st.isEmpty()) {
Pair p = st.poll();
if (p.node.left != null && p.node.left != block) {
st.add(new Pair(p.node.left, p.state + 1));
if (p.state + 1 == k) {
System.out.print(p.node.left.data + " ");
}
}
if (p.node.right != null && p.node.right != block) {
st.add(new Pair(p.node.right, p.state + 1));
if (p.state + 1 == k) {
System.out.print(p.node.right.data + " ");
}
}
}
}
// PRINT K FAR
public static void printKfar(Node root, int target, int k) {
ArrayList path = Node2RootPath(root, target);
for (int i = 0; i < path.size() && i 0) {
Pair top = st.peek();
if (top.state == 1) {
index++;
if (arr[index] != null) {
Node ln = new Node(arr[index], null, null);
top.node.left = ln;
Pair lp = new Pair(ln, 1);
st.push(lp);
}
top.state++;
} else if (top.state == 2) {
index++;
if (arr[index] != null) {
Node ln = new Node(arr[index], null, null);
top.node.right = ln;
Pair lp = new Pair(ln, 1);
st.push(lp);
}
top.state++;
} else {
st.pop();
}
}
// System.out.println(Node2RootPath(root, 25));
printKfar(root, 62, 2);
}
koi bataega mera kaha galat code hai please:
class Solution {
public:
vectorv;
vectorv1;
bool find(TreeNode* root,int key)
{
if(!root)
{
return false;
}
if(root->val==key)
{
v.push_back(root);
return true;
}
bool f1=find(root->left,key);
if(f1)
{
v.push_back(root);
return true;
}
bool f2=find(root->right,key);
if(f2)
{
v.push_back(root);
return true;
}
return false;
}
void print(TreeNode* root,int k,TreeNode* blocker)
{
if(!root||kval);
return;
}
print(root->left,k--,blocker);
print(root->right,k--,blocker);
}
vector distanceK(TreeNode* root, TreeNode* target, int k)
{
int data=target->val;
find(root,data);
for(int i=0;i
yes, post the same code on nados.pepcoding.com, community will help you out there.