Given the root of a binary tree, calculate the vertical order traversal of the binary tree. For each node at position (row, col), its left and right children will be at positions (row + 1, col - 1) and (row + 1, col + 1) respectively. The root of the tree is at (0, 0). The vertical order traversal of a binary tree is a list of top-to-bottom orderings for each column index starting from the leftmost column and ending on the rightmost column. There may be multiple nodes in the same row and same column. In such a case, the node that appears in any of left subtrees is the first one in the vertical ordering. Return the vertical order traversal of the binary tree.
CodingMid-level
Leetcode 987. Vertical Order Traversal of a Binary Tree
Assign each node coordinates (row, col) with root at (0,0) and children at (r+1,c±1), then produce a list of columns from leftmost to rightmost where nodes in each column are ordered by increasing row and, for nodes with the same row and column, by increasing node value.
Contextos reais
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Metaseniornov. de 2025
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.