{ "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
给你一个整数 n
,请你找出所有可能含 n
个节点的 真二叉树 ,并以列表形式返回。答案中每棵树的每个节点都必须符合 Node.val == 0
。
答案的每个元素都是一棵真二叉树的根节点。你可以按 任意顺序 返回最终的真二叉树列表。
\n\n真二叉树 是一类二叉树,树中每个节点恰好有 0
或 2
个子节点。
\n\n
示例 1:
\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
示例 2:
\n\n\n输入:n = 3\n输出:[[0,0,0]]\n\n\n
\n\n
提示:
\n\n1 <= n <= 20