Recursion Base Condition Mistake
In recursion, sometimes we want the base condition to be something like this:
def recursion(first: Optional[Node], second: Optional[Node]):
if not first and not second: return True
if not first or not second: return False
Just make sure when you do this, always do the and
condition first before the or
.
Because if first = None
and second = None
, not first or not second
is also True