Skip to content

Instantly share code, notes, and snippets.

@Nader93
Last active May 2, 2019 16:10
Show Gist options
  • Save Nader93/c2d13686c81cad656df6a835778609f3 to your computer and use it in GitHub Desktop.
Save Nader93/c2d13686c81cad656df6a835778609f3 to your computer and use it in GitHub Desktop.
Binary Tree Nodes hackerrank (best solution)
select case
when p is null then concat(n, ' Root')
when n in (select distinct p from bst) then concat(n, ' Inner')
else concat(n, ' Leaf')
end
from bst
order by n asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment