One of the rare occasions when I did a recursive problem by myself!! Also I had exact same solution as sir This is one of the most intuitive DFS problems out there.
'self' refers to an instance/object of a class, and whatever we do with self. (dot after self), it accesses attributes and functions specific to that instance of the class. Let's say we have a class ABC. class ABC: def __init__(self, n): self.name = n def print_name(self): print(self.name) We create 2 instances of same class: a = ABC("obj1") b = ABC("obj2") a.print_name() # It will print obj1 b.print_name() # It will print obj2 So, inside the 2 calls of print_name() 'self 'is denoting instances a and b respectively.
One of the rare occasions when I did a recursive problem by myself!!
Also I had exact same solution as sir
This is one of the most intuitive DFS problems out there.
Brilliantly done
sir please can you solve more of graph problems? I have my Campus selection starting from next month and I'm weak in Graphs.
Bhai campus placement me k liye college ka khulna bhi to zarrori hain
ravi ashwin virtual chal raha hai bhai
Great
Nice explanation.
Nice explanation sir
Do they ask to solve in iterative way? it doesn't even seem efficient?
sir please make more make videos on graphs than leetcode.
Yes. Adding.
What is meant by self.isSameTree
Why are we using self here
Please anyone explain
'self' refers to an instance/object of a class, and whatever we do with self. (dot after self), it accesses attributes and functions specific to that instance of the class.
Let's say we have a class ABC.
class ABC:
def __init__(self, n):
self.name = n
def print_name(self):
print(self.name)
We create 2 instances of same class:
a = ABC("obj1")
b = ABC("obj2")
a.print_name() # It will print obj1
b.print_name() # It will print obj2
So, inside the 2 calls of print_name() 'self 'is denoting instances a and b respectively.
Didn't understand the iterative approach at all !