O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

Mirror BST

Suhas S Inglês 1 flashcard

Flashcards do conjunto (1)

  1. 1Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1class Solution {
    public TreeNode invertTree(TreeNode root) {
    if(root ==null) {
    return root;
    }
    root=invertOperation(root,root.left,root.right);
    return root;
    }
    public TreeNode invertOperation(TreeNode root,TreeNode left,TreeNode right) {
    if(root ==null) {
    return root;
    }
    if(left!=null) {
    invertOperation(left,left.left,left.right);
    }
    TreeNode temp=new TreeNode(0);
    temp=root.left;//temp=1
    root.left=root.right;//left=3
    root.right=temp;//right=1
    if(right!=null) {
    invertOperation(right,right.left,right.right);
    }
    return root;
    }
    }

Informações

Descrição
FlashCards sobre Mirror BST, criado por Suhas S em 12-05-2018.
Criado por
Suhas S
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?