We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63d3ece commit c2f50abCopy full SHA for c2f50ab
ruby/100-Same-Tree.rb
@@ -0,0 +1,11 @@
1
+def is_same_tree(p, q)
2
+ if p.nil? && q.nil?
3
+ true
4
+ elsif p && q
5
+ (p.val == q.val) &&
6
+ is_same_tree(p.left, q.left) &&
7
+ is_same_tree(p.right, q.right)
8
+ else
9
+ false
10
+ end
11
+end
0 commit comments