Skip to content

Commit c2f50ab

Browse files
committed
100
1 parent 63d3ece commit c2f50ab

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ruby/100-Same-Tree.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)