Easy and Simple solution✅✅✅ using Case only.
Tree Node\n\n# Write your MySQL query statement below\nSELECT id,\n    CASE  \n        WHEN p_id IS NULL \n           THEN \'Root\'        \n        WHEN id IN 
**Tree Node**\n```\n# Write your MySQL query statement below\nSELECT id,\n    CASE  \n        WHEN p_id IS NULL \n           THEN \'Root\'        \n        WHEN id IN (SELECT p_id FROM tree) \n            THEN \'Inner\'            \n        ELSE \'Leaf\'       \n    END AS Type\n        FROM tree\n```\n\nRuntime: 377 ms, **faster** than **84.18%** of MySQL online submissions for Tree Node.\nMemory Usage: 0B, less than **100.00%** of MySQL online submissions for Tree Node.
[]