Skip to content

Instantly share code, notes, and snippets.

@munguial
Created July 15, 2020 06:14
Show Gist options
  • Save munguial/ec24135f40f68a4a33a7c25aa7750abf to your computer and use it in GitHub Desktop.
Save munguial/ec24135f40f68a4a33a7c25aa7750abf to your computer and use it in GitHub Desktop.
July - Day 13 - Same Tree
// https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/545/week-2-july-8th-july-14th/3389/
public class Solution {
public boolean isSameTree(TreeNode p, TreeNode q) {
if(p == null && q == null)
return true;
if(p == null || q == null)
return false;
if(p.val != q.val)
return false;
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment