Loading problem...
You are given a table named tree that describes a rooted hierarchy.
Columns:
The dataset always forms one valid tree:
Classify every node into one of three labels:
Return exactly two columns:
Rows may be returned in any order.
Supported submission environments:
tree:
| id | p_id |
|----|------|
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 2 |[
{"id":1,"type":"Root"},
{"id":2,"type":"Inner"},
{"id":3,"type":"Leaf"},
{"id":4,"type":"Leaf"},
{"id":5,"type":"Leaf"}
]Node 1 has no parent, so it is Root. Node 2 has both a parent and children, so it is Inner. Nodes 3, 4, and 5 have no children, so they are Leaf.
tree:
| id | p_id |
|----|------|
| 10 | null |[
{"id":10,"type":"Root"}
]A single-node tree has only one node, and it must be Root.
tree:
| id | p_id |
|-----|------|
| 90 | 30 |
| 20 | 10 |
| 10 | null |
| 30 | 10 |
| 40 | 20 |
| 50 | 20 |
| 60 | 50 |[
{"id":10,"type":"Root"},
{"id":20,"type":"Inner"},
{"id":30,"type":"Inner"},
{"id":40,"type":"Leaf"},
{"id":50,"type":"Inner"},
{"id":60,"type":"Leaf"},
{"id":90,"type":"Leaf"}
]Node 10 is Root. Nodes 20, 30, and 50 each have children, so they are Inner. Remaining non-root nodes without children are Leaf.
Constraints