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.
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.
Given the reference to a binary tree, return the length of the longest path in the tree that contains consecutive values.
Given a binary tree, return the bottom-left most value.
Given a binary search tree, return its mode (you may assume the answer is unique). If the tree is empty, return -1.
This question is asked by Facebook. You are given a two dimensional matrix, friends, that represents relationships between coworkers in an office. If friendsi = 1 then coworker i is friends with coworker j and coworker j is friends with coworker i. Similarly if friendsi = 0 then coworker i is not friends with coworker j and coworker j is not friend with coworker i. Friendships in the office are transitive (i.e., if coworker one is friends with coworker two and coworker two is friends with coworker three, coworker one is also friends with coworker three). Given the friendships in the office defined by friends, return the total number of distinct friends groups in the office.
This question is asked by Facebook. Given an undirected graph, determine whether it is bipartite.
This question is asked by Amazon. Given N distinct rooms that are locked, we want to know if you can unlock and visit every room. Each room has a list of keys in it that allows you to unlock and visit other rooms. We start with room 0 being unlocked. Return whether or not we can visit every room.
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.
Given the reference to a binary search tree, return the kth smallest value in the tree.
You are given a two-dimensional matrix that represents a plot of land. Within the matrix there exist two values: ones which represent land and zeroes which represent water within a pond. Given that parts of a pond can be connected both horizontally and vertically (but not diagonally), return the largest pond size.
Given a 2D array grid, where zeroes represent water and ones represent land, return the size of the largest island.
This question is asked by Google. Given an N-ary tree, return its maximum depth.
Given a 2D array of integers with ones representing land and zeroes representing water, return the number of islands in the grid.
You're about to set sail off a pier and first want to count the number of ships that are already in the harbor. The harbor is deemed safe to sail in if the number of boats in the harbor is strictly less than limit. Given a 2D array that presents the harbor, where O represents water and S represents a ship, return whether or not it's safe for you to set sail.
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.
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.
This question is asked by Amazon. Given a 2D matrix that represents a gold mine, where each cell's value represents an amount of gold, return the maximum amount of gold you can collect given the following rules:
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).
This question is asked by Amazon. Given two trees s and t, return whether or not t is a subtree of s.
Given a binary tree, return the sum of all left leaves of the 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).
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.
Given a binary tree, containing unique values, determine if it is a valid binary search tree.
This question is asked by Amazon. Given a 2D board that represents a word search puzzle and a string word, return whether or the given word can be formed in the puzzle by only connecting cells horizontally and vertically.