일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 백준
- 코테
- 조지프 나이
- 데이터분석전문가가이드
- 알고리즘
- 후기
- Progate
- Joseph Samuel Nye Jr.
- ADP
- Great Minds
- 미분적분학
- EBS
- ADsP
- 위대한 수업
- 공부정리
- Baekjoon
- KMOOC
- 당신이 몰랐던 진화론
- 데이터분석전문가
- 맛집
- python
- CNN10
- Udemy
- 자료구조
- 정치학
- 누가 진정한 리더인가
- 빅데이터
- Hacker Rank
- MySQL
- K-MOOC
Archives
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#Binary Tree Nodes 본문
SQL > Advanced Select > Binary Tree Nodes
Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:
- Root: If node is root node.
- Leaf: If node is leaf node.
- Inner: If node is neither root nor leaf node.
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
SELECT N,
CASE
WHEN P IS NULL
THEN 'Root'
ELSE CASE
WHEN N IN (SELECT P FROM BST)
THEN 'Inner'
ELSE 'Leaf'
END
END
FROM BST
ORDER BY N ASC
반응형
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#Symmetric Pairs (0) | 2022.03.01 |
---|---|
[Hacker Rank_MySQL]문제 풀이#New Companies (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Weather Observation Station 19 (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#The PADS (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Challenges (0) | 2022.03.01 |
Comments