You are given n nodes in a binary tree, numbered from 0 to n-1. Each node i has two children: leftChild[i] and rightChild[i]. If a node has no left child, its value will be -1. Similarly, if a node has no right child, its value will also be -1. Your task is to return true if and only if these nodes form exactly one valid binary tree.
You are given a binary tree and a linked list. Determine if there exists a downward path in the binary tree that matches all elements of the linked list starting from its head node. A downward path means starting from any node in the binary tree and following child nodes downwards.
Given the root of a binary tree, find the length of the longest ZigZag path in the tree. A ZigZag path is one where you move left and right alternately, starting from any node.
A company has n employees with a unique ID for each employee from 0 to n-1. The head of the company is the one with headID. Each employee has one direct manager. The head will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news. Each employee needs informTime[i] minutes to inform their direct subordinates. Return the total time required to inform all employees.
You are given two binary trees: an original tree and a cloned tree. The cloned tree is a copy of the original tree, and you are given a reference to a node in the original tree. Your task is to return the reference to the corresponding node in the cloned tree.
Given the root of a binary search tree (BST), return a balanced BST containing the same node values. A balanced BST is one where the depth of the left and right subtrees of every node never differ by more than 1.