MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / isSameTree

Method isSameTree

src/com/blankj/easy/_0100/Solution.java:15–19  ·  view source on GitHub ↗
(TreeNode p, TreeNode q)

Source from the content-addressed store, hash-verified

13 */
14public class Solution {
15 public boolean isSameTree(TreeNode p, TreeNode q) {
16 if (p == null || q == null) return p == q;
17 if (p.val != q.val) return false;
18 return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
19 }
20
21 public static void main(String[] args) {
22 Solution solution = new Solution();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected