Package g0001_0100.s0100_same_tree
Class Solution
java.lang.Object
g0001_0100.s0100_same_tree.Solution
100 - Same Tree.<p>Easy</p>
<p>Given the roots of two binary trees <code>p</code> and <code>q</code>, write a function to check if they are the same or not.</p>
<p>Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg" alt="" /></p>
<p><strong>Input:</strong> p = [1,2,3], q = [1,2,3]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/12/20/ex2.jpg" alt="" /></p>
<p><strong>Input:</strong> p = [1,2], q = [1,null,2]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/12/20/ex3.jpg" alt="" /></p>
<p><strong>Input:</strong> p = [1,2,1], q = [1,1,2]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in both trees is in the range <code>[0, 100]</code>.</li>
<li><code>-10<sup>4</sup> <= Node.val <= 10<sup>4</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isSameTree
-