## DEV Community π©βπ»π¨βπ» is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Joao Carlos Sousa do Vale

Posted on

# Technical Interview - Code #006 - LeetCode #814. Binary Tree Pruning

Medium

Linear

## Topicos

Arvores Binarias, Travessia Pre-Ordem

## Problema

Dada a raiz de uma Γ‘rvore binΓ‘ria, devolva a mesma Γ‘rvore onde cada sub-Γ‘rvore (da Γ‘rvore dada) que nΓ£o contenha um 1 foi removida.

RestriΓ§Γ΅es:

O nΓΊmero de nΓ³s na Γ‘rvore estΓ‘ na faixa [1, 200].
O nΓ³.val ou Γ© 0 ou 1.

## Exemplo

Β

Example 1:

```Input: root = [1,null,0,0,1]
Output: [1,null,0,null,1]
```

Example 2:

```Input: root = [1,0,1,0,0,0,1]
Output: [1,null,1,null,1]
```

Example 3:

```Input: root = [1,1,0,1,1,0,1,0]
Output: [1,1,0,1,1,null,1]
```

## Implementar

``````class Solution {
public TreeNode pruneTree(TreeNode root) {

}
}
``````

## Fonte

LeetCode #814. Binary Tree Pruning
https://leetcode.com/problems/binary-tree-pruning/