Skip to content

Latest commit

 

History

History

Tree Node

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Star Badge View Main Folder View Repositories View My Profile


🛠️ Problem Statement

Table Name : Queue

Column Name Type
id int
p_id varchar
  • id is the column with unique values for this table.
  • Each row of this table contains information about the id of a node and the id of its parent node in a tree (represented by p_id).
  • The given structure is always a valid tree.

Each node in the tree can be one of three types:

  • "Leaf": if the node is a leaf node.
  • "Root": if the node is the root of the tree.
  • "Inner": If the node is neither a leaf node nor a root node.

Write a solution to report the type of each node in the tree.

Return the result table in any order.

The result format is in the following example.

Sample Example


Input

Table Name: Queue

id p_id
1 null
2 1
3 1
4 2
5 2
Output
id type
1 Root
2 Inner
3 Leaf
4 Leaf
5 Leaf