Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- lv0
- Programmers
- 자바
- Stack
- 프로그래머스
- StringTokenizer
- 스프링부트 도커 배포
- 백준 N과 M 자바
- COS Pro
- java
- 프로그래머스 자바
- 이진수 변환
- 스택
- 큐
- 스프링부트 도커
- 스프링부트 도커로 배포
- 클라이언트
- 버퍼
- 오름차순 정렬
- index of
- 프로그래머스 풀이
- 알고리즘
- SWEA
- 문자열
- Queue
- lv2
- Lv1
- 삼각형의 완성조건
- 프로그래머스 문자열 정렬
- 백준
Archives
- Today
- Total
mun dev
[HackerRank] Binary Tree Nodes 오라클 풀이 본문
문제링크
Binary Tree Nodes | HackerRank
Write a query to find the node type of BST ordered by the value of the node.
www.hackerrank.com
풀이
세 개의 케이스로 나누어서 생각하면 수월하게 풀이할 수 있다.
p가 null이라면 Root
n과 p가 같다면 Inner
모두 아닌 경우라면 Leaf
코드
select N,
(case when p is null
then 'Root'
when exists (select p
from BST T
where B.N = T.P)
then 'Inner' else 'Leaf' end)
from BST B
order by N;
'알고리즘 > HackerRank' 카테고리의 다른 글
[HackerRank] Weather Observation Station 5 오라클 풀이 (0) | 2024.01.29 |
---|---|
[HackerRank] Occupations 오라클 풀이 (0) | 2024.01.29 |
[HackerRank] Weather Observation Station 18 오라클 풀이 (0) | 2024.01.26 |
[HackerRank] New Companies 오라클 풀이 (0) | 2024.01.26 |
[HackerRank] The PADs 오라클 풀이 (0) | 2024.01.26 |