Same Tree | DFS | BFS | Google | Leetcode 100

preview_player
Показать описание
This is the 20th Video of our Binary Tree Playlist.
In this video we will try to solve a very easy but good and pretty popular problem "Same Tree".

We will do live coding after explanation and see if we are able to pass all the test cases.

Problem Name : Same Tree
Company Tags : Google, Adobe, Meta, Amazon, Uber, Bloomberg, MentorGraphics

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

Thanks a lot bhaiya ❤❤ and congrats on 22k subs. Finally the sub count of your channel has taken a rapid growth. I hope you get the recognition you really deserve😇.

gauravbanerjee
Автор

I feel like I am improving day by day. Thanks a lot
I am preparing for my coding interviews.

souravjoshi
Автор

Every time you don’t quit, you beat someone who did - Nov 19

repeat the above sentence and focus on learning, improvement and practice....

heyOrca
Автор

Your subscribers are going to increase upto 100k in coming 2 months..great work sir ❤

jeethora
Автор

easy...solved it by my own using recursion but your second approach is also interesting and easy to understand... thank you 😊😊

abhinavkumar
Автор

Great, waiting for next concept video

manishv.
Автор

Tried this solution using the preorder approach from yesterday:
class Solution {
public:
void preorder(TreeNode* node, vector<int> &pre){
if(node == NULL){pre.push_back(-1); return;}

pre.push_back(node->val);
preorder(node->left, pre);
preorder(node->right, pre);
}
bool isSameTree(TreeNode* p, TreeNode* q) {
if(p==NULL && q==NULL)return true;

if(p==NULL || q==NULL)return false;

vector<int> pre1;
vector<int> pre2;

preorder(p, pre1);
preorder(q, pre2);

return pre1==pre2;
}
};

P.S. love your videos learning a lot everyday. Thank you for the longer videos containing brute force approaches as well.

anantsingh
Автор

feels great that i am improving
i did this on my own :)
all thanks to you ....u just helped a lot in improving my coding skills through story based approach

oqant
Автор

I am in my first year and learning from your approaches.💪
BTW, did the recursive code myself but didn't bother doing the iterative one.😂😂

shricodev
Автор

Nice explanation 👍, today's problem

kailash_
Автор

sir please make a video on serialise and deserialise a binary tree

SahilKumar-rwsh
Автор

came here to learn the iterative approach from u :)

oqant
Автор

Thanks for all your intuitive and engaging explanations! May I know which software are you using in iPad for writing?

tauhait
Автор

public boolean isSameTree(TreeNode p, TreeNode q) {
if (p == null || q == null) return p == q;
if (p.val != q.val) return false;
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
}

TechieTech-gxkd
Автор

How do you know which company asked this question? Btw nice explanation.

mohammedwaseem
Автор

iski multiple approaches hai usme se recursion ya dusri video aayegi kya??

harshtiwari
visit shbcf.ru