Junior — Senior
Checking the identity of two binary trees
livecode
Task condition
The method takes two binary trees as input and returns true if their structure and node values completely match; otherwise, it returns false.
class TreeNode {
int val;
TreeNode left;
TreeNode right;
}
class TreeTask {
public boolean isSameTree(TreeNode p, TreeNode q) {
// TODO
}
}