~고군분투 인생살이~

[MEDIUM] Binary Tree Nodes 본문

SQL/HACKER_RANK

[MEDIUM] Binary Tree Nodes

소금깨 2022. 10. 12. 02:51
 

Binary Tree Nodes | HackerRank

Write a query to find the node type of BST ordered by the value of the node.

www.hackerrank.com

 

 

문제 풀이 

select n,
        (case when p is null then "Root"
             when n in (select p from BST) then "Inner"
         else "Leaf"
        end)
from BST 
order by n

 

'SQL > HACKER_RANK' 카테고리의 다른 글

[EASY] Japanese Cities' Attributes  (0) 2022.10.13
[EASY] Select By ID  (0) 2022.10.13
[MEDIUM] The PADS  (0) 2022.10.12
[EASY] Select All  (0) 2022.10.12
[EASY] Revising the Select Query II  (0) 2022.10.11
Comments