AC solution using case


  • 0
    J

    select t.id as id,
    (case
    when t.p_id is null** then 'Root'
    when t.id in (select p_id from tree) then 'Inner'
    else 'Leaf'
    end
    ) Type
    from tree t;


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.