Binary Tree Nodes MediumSQL (Intermediate) – HackerRank Solution SQL, Best and Optimal Solutions , All you need.
Solutions of SQL all HackerRank:
Here are all the Solutions of All of SQL of Hacker Rank , Leave a comment for similar posts
SQL Binary Tree Nodes MediumSQL (Intermediate) HackerRank Solution
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
*/
WITH RECS AS
(SELECT N,CONNECT_BY_ISLEAF LEAF,(CASE WHEN P IS NULL THEN 0 ELSE 1 END) ROOTNODE
FROM BST
START WITH P IS NULL
CONNECT BY PRIOR N=P)
SELECT N,
(CASE WHEN (R.LEAF=1) THEN 'Leaf'
WHEN (R.LEAF=0 AND ROOTNODE=1) THEN 'Inner'
ELSE 'Root' END)
FROM RECS R
ORDER BY 1;
SQL (Basic)
SQL (Intermediate)
SQL (Advanced)
Basic Select
Advanced Select
Aggregation
Basic Join
Advanced Join
Alternative Queries
Leave a comment below