MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / isSameTree

Method isSameTree

TreeSameTree.java:2–11  ·  view source on GitHub ↗
(TreeNode p, TreeNode q)

Source from the content-addressed store, hash-verified

1class Solution {
2 public boolean isSameTree(TreeNode p, TreeNode q) {
3
4 if(p==null || q==null)
5 {
6 return (p==q);
7 }
8
9 return (p.val==q.val) && isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
10
11 }
12}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected