Tag: depth first search algorithm
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: We can use the …
Given preorder and inorder traversal of a tree, construct the binary tree. You may assume that duplicates do not exist in the tree. For example, given preorder = inorder …
You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get …
You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not …
Given the root of a binary tree, find the maximum average value of any subtree of that tree. (A subtree of a tree is any node of that tree …