Questions with My Top-Down Definition Pattern

Symmetric Tree

Estimated reading: 1 minute 28 views
				
					private boolean isMirror(TreeNode left, TreeNode right) {
    if (left == null && right == null) {
        return true;
    }

    if (left == null || right == null) {
        return false;
    }

    return (left.val == right.val)
        && isMirror(left.left, right.right)
        && isMirror(left.right, right.left);
}

				
			
Share this Doc

Symmetric Tree

Or copy link

CONTENTS