Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-04-28_17-14-32.png
26.5 KB
#medium
#N608. Tree Node
problem link
#solution
select id, 'Root' as type from tree where p_id is null
union
select id, 'Inner' as type from tree
where id in (select distinct p_id from tree where p_id is not null) and p_id is not null
union
select id, 'Leaf' as type from tree
where id not in(select distinct p_id from tree where p_id is not null) and p_id is not null