Class Solution

java.lang.Object
g0201_0300.s0226_invert_binary_tree.Solution

public class Solution extends Object
226 - Invert Binary Tree.<p>Easy</p> <p>Given the <code>root</code> of a binary tree, invert the tree, and return <em>its root</em>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg" alt="" /></p> <p><strong>Input:</strong> root = [4,2,7,1,3,6,9]</p> <p><strong>Output:</strong> [4,7,2,9,6,3,1]</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/03/14/invert2-tree.jpg" alt="" /></p> <p><strong>Input:</strong> root = [2,1,3]</p> <p><strong>Output:</strong> [2,3,1]</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> root = []</p> <p><strong>Output:</strong> []</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the tree is in the range <code>[0, 100]</code>.</li> <li><code>-100 <= Node.val <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details