{ "data": { "question": { "questionId": "930", "questionFrontendId": "894", "categoryTitle": "Algorithms", "boundTopicId": 1727, "title": "All Possible Full Binary Trees", "titleSlug": "all-possible-full-binary-trees", "content": "
Given an integer n
, return a list of all possible full binary trees with n
nodes. Each node of each tree in the answer must have Node.val == 0
.
Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order.
\n\nA full binary tree is a binary tree where each node has exactly 0
or 2
children.
\n
Example 1:
\n\n\nInput: n = 7\nOutput: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]\n\n\n
Example 2:
\n\n\nInput: n = 3\nOutput: [[0,0,0]]\n\n\n
\n
Constraints:
\n\n1 <= n <= 20
满二叉树是一类二叉树,其中每个结点恰好有 0 或 2 个子结点。
\n\n返回包含 N
个结点的所有可能满二叉树的列表。 答案的每个元素都是一个可能树的根结点。
答案中每个树的每个结点
都必须有 node.val=0
。
你可以按任何顺序返回树的最终列表。
\n\n\n\n
示例:
\n\n输入:7\n输出:[[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]\n解释:\n\n\n\n
\n\n
提示:
\n\n1 <= N <= 20