剑指offer
二叉树的镜像
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:504880
本题知识点:
树
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
操作给定的二叉树,将其变换为源二叉树的镜像。
输入描述:
二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9 7 5
说明:本题目包含复杂数据结构TreeNode,
点此查看相关信息
上一题
登录
/
注册
我的提交
编辑器加载中...
/** public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { public void Mirror(TreeNode root) { } }
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: void Mirror(TreeNode *pRoot) { } };
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 返回镜像树的根节点 def Mirror(self, root): # write code here
/* public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode (int x) { val = x; } }*/ class Solution { public TreeNode Mirror(TreeNode root) { // write code here } }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function Mirror(root) { // write code here } module.exports = { Mirror : Mirror };
val = $val; } }*/ function Mirror(&$root) { // write code here }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function Mirror(root) { // write code here }
# class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # # @param pRoot TreeNode类 # @return void # class Solution: def Mirror(self , pRoot ): # write code here
package main import . "nc_tools" /* * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ /** * * @param pRoot TreeNode类 * @return TreeNode类 */ func Mirror( pRoot *TreeNode ) *TreeNode { // write code here }
/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * * @param pRoot TreeNode类 * @return TreeNode类 */ struct TreeNode* Mirror(struct TreeNode* pRoot ) { // write code here }