Leetcode - Invert Binary Tree
https://leetcode.com/problems/invert-binary-tree/
Invert a binary tree.
Example:
Input:
4 / \ 2 7 / \ / \ 1 3 6 9
Output:
4 / \ 7 2 / \ / \ 9 6 3 1
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func invertTree(root *TreeNode) *TreeNode { invert(root) return root } func invert(node *TreeNode) { if node == nil { return } node.Left, node.Right = node.Right, node.Left invert(node.Left) invert(node.Right) }
Sep 22, 2021 11:17:09 AM
Hope there are lots of new things that can be learned from this website.
Nov 09, 2022 10:00:45 PM
Quality education is a combination of a proper and effective education system. The Indian education department seeks to streamline and provide quality and improved education to all students in the country. Shaala Siddhi login The National Programme on School Standards and Evaluation NPSSE ensure the country’s education system is effective and in line with the student’s needs. The NPSSE offers comprehensive and inclusive school evaluation programmes to benefit all students.