判断对称二叉树

190 阅读1分钟
//判断对称二叉树

function isSameTree(root) {
	const isMrror = (left, right) => {
		if (left === null && right === null){
			return true;
		}else{
			if (left && right){
				return (left.val === right.val && isMrror(left.right, right.left) && isMrror(left.left, right.right))
			}else{
				return false;
			}
		}
	}
	if (!root){
		return true;
	}else{
		return isMrror(root.left, root.right);
	}
}