Leetcode in Java && Oracle
424 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2023-01-10_19-12-08.png
24.3 KB
Runtime0 msBeats100%
Memory40 MBBeats62.93%
#N100. Same Tree
problem link
#solution
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);
}
}
👍4