Solución
solution.tsTypeScript
interface TreeNode {
value: number;
left: TreeNode | null;
right: TreeNode | null;
}
function maxDepth(root: TreeNode | null): number {
if(!root) return 0;
if(root.left) return maxDepth(root.left) + 1
if(root.right) return maxDepth(root.right) + 1
return 1;
}
// No modificar: necesario para evaluar el resultado.
export { maxDepth };0respuestas