MCPcopy Create free account
hub / github.com/Sugapriyan-P-K/blind75 / isSameTree

Method isSameTree

Trees/62sameTree/sameTree.java:3–11  ·  view source on GitHub ↗
(tree p, tree q)

Source from the content-addressed store, hash-verified

1public class sameTree {
2
3 public static boolean isSameTree(tree p, tree q) {
4 if (p == null && q == null) {
5 return true;
6 }
7 if (p == null || q == null || p.val != q.val) {
8 return false;
9 }
10 return (isSameTree(p.left, q.left) && isSameTree(p.right, q.right));
11 }
12
13 public static void main(String[] args) {
14 tree root = new tree(1, new tree(2), new tree(3));

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected