Novo curso: Como conseguir vagas remotas em empresas que pagam $120k+/ano
NaGringa
CodingMid-level

Leetcode 104. Maximum Depth of Binary Tree

Given the root of a binary tree, return its maximum depth — the number of nodes along the longest root-to-leaf path. This classic easy problem is solved by a DFS or level-order traversal in O(n) time (n ≤ 10^4).

Empresas em que apareceu
LinkedInLinkedInGoogleGoogle
Contextos reais

Onde essa pergunta já apareceu

Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.

LinkedInmidfev. de 2026

Given a tree, determine its depth; that is the number of nodes in the path from the root to the farthest leaf. Please fill in the following function to find the max depth of a tree using the following Node API. (GIVEN) Abstract class that holds a tree node """ # class Node { # def getValue() -> int; # def getLeft() -> Node: // May return null if no left/right child exists # def getRight() -> Node; // May return null if no left/right child exists # }

Googlejuniorout. de 2024

Calculate the depth of a binary tree

Anexos públicos

Materiais associados

Nenhum anexo público associado a esta pergunta.

Próximo passo

Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.

Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.

Continue a preparação com o banco completo

No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.