Pular para o conteúdo principal

35 documentos selecionados com "tree"

Ver todas os Marcadores

Average of Levels in Binary Tree

This question is asked by Facebook. Given a reference to the root of a binary tree, return a list containing the average value in each level of the tree.

Binary Tree Column Order Traversal

Given a binary tree, return its column order traversal from top to bottom and left to right. Note: if two nodes are in the same row and column, order them from left to right.

Binary Tree Left Side View

Given a binary tree, return all the values you'd be able to see if you were standing on the left side of it with values ordered from top to bottom.

Binary Tree Level Order Traversal II

Given a binary tree, return its level order traversal where the nodes in each level are ordered from left to right, and the levels are ordered from bottom to top.

House Robber Binary Tree

You're a thief trying to rob a binary tree. As a thief, you are trying to steal as much money as possible. The amount of money you steal is equivalent to the sum of all the node's values that you decide to rob. If two adjacent nodes are robbed, the authorities are automatically alerted. Return the maximum loot that you can steal without alerting the authorities.

Increasing Order Search Tree

Given a binary search tree, rearrange the tree such that it forms a linked list where all its values are in ascending order.

Insert into Binary Search Tree

Given the reference to a binary search tree and a value to insert, return a reference to the root of the tree after the value has been inserted in a position that adheres to the invariants of a binary search tree.

Kill Process

You are given two lists of integers and an integer representing a process id to kill. One of the lists represents a list of process ids and the other represents a list of each of the processes' corresponding (by index) parent ids. When a process is killed, all of its children should also be killed. Return a list of all the process ids that are killed as a result of killing the requested process.

Level Up Binary Search Tree

Given the reference to a binary search tree, "level-up" the tree. Leveling-up the tree consists of modifying every node in the tree such that every node's value increases by the sum of all the node's values that are larger than it.

Mode in Binary Search Tree

Given a binary search tree, return its mode (you may assume the answer is unique). If the tree is empty, return -1. Note: the mode is the most frequently occurring value in the tree.

Path Sum

Given a binary tree and a target, return whether or not there exists a root to leaf path such that all values along the path sum to the target.

Path Sum III

Given the reference to the root of a binary tree and a value k, return the number of paths in the tree such that the sum of the nodes along the path equals k.

Range Sum of BST

This question is asked by Facebook. Given the root of a binary tree and two values low and high, return the sum of all values in the tree that are within low and high (inclusive).

Same Tree

Given two binary trees, return whether or not the two trees are identical. Note: identical meaning they exhibit the same structure and the same values at each node.

Search in a Binary Search Tree

Given the reference to the root of a binary search tree and a search value, return the reference to the node that contains the value if it exists and null otherwise.

Subtree of Another Tree

This question is asked by Amazon. Given two trees s and t, return whether or not t is a subtree of s.

Symmetric Tree

Given a binary tree, return whether or not it forms a reflection across its center (i.e. a line drawn straight down starting from the root).

Trim Dead Nodes from Binary Tree

You are given the reference to the root of a binary tree and are asked to trim the tree of "dead" nodes. A dead node is a node whose value is listed in the provided dead array. Once the tree has been trimmed of all dead nodes, return a list containing references to the roots of all the remaining segments of the tree.

Two Sum IV - Input is a BST

Given the reference to the root of a binary search tree and a target value, return whether or not two individual values within the tree can sum to the target.