From 3606be45c16c885440cecc560d80b43e6b0124a5 Mon Sep 17 00:00:00 2001 From: bt3gl <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:52:00 -0700 Subject: [PATCH] Update bt_is_same_trees.py --- trees/bt_is_same_trees.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/trees/bt_is_same_trees.py b/trees/bt_is_same_trees.py index cdaab4b..f814aa9 100644 --- a/trees/bt_is_same_trees.py +++ b/trees/bt_is_same_trees.py @@ -2,15 +2,13 @@ # -*- coding: utf-8 -*- # author: bt3gl + def is_same_trees(p, q): if not p and not q: return True - if (not p and q) or (not q and p): - return False - - if p.val != q.val: + if (not p and q) or (not q and p) or p.val != q.val: return False return self.is_same_trees(p.right, q.right) and self.is_same_trees(p.left, q.left)