Created
July 15, 2020 06:14
-
-
Save munguial/ec24135f40f68a4a33a7c25aa7750abf to your computer and use it in GitHub Desktop.
July - Day 13 - Same Tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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