608. Tree Node

2022. 5. 30. 21:58· 자료구조 알고리즘/코딩테스트

https://leetcode.com/problems/tree-node/

 

Tree Node - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

select id, 
    case when p_id is null then 'Root' 
        when id in (select distinct p_id from Tree) then 'Inner'
        else 'Leaf' end as type
from Tree;

best

select
id, IF(ISNULL(p_id), 'Root', 
       IF(id in (SELECT p_id from tree),'Inner', 'Leaf')) as Type
from Tree
728x90
반응형

'자료구조 알고리즘 > 코딩테스트' 카테고리의 다른 글

70. Climbing Stairs  (0) 2022.05.31
176. Second Highest Salary  (0) 2022.05.30
1795. Rearrange Products Table  (0) 2022.05.30
1965. Employees With Missing Information  (0) 2022.05.30
1527. Patients With a Condition  (0) 2022.05.30
'자료구조 알고리즘/코딩테스트' 카테고리의 다른 글
  • 70. Climbing Stairs
  • 176. Second Highest Salary
  • 1795. Rearrange Products Table
  • 1965. Employees With Missing Information
내공얌냠
내공얌냠
내공냠냠
내공얌냠
내공냠냠
내공얌냠
전체
오늘
어제
  • 분류 전체보기 (254)
    • 개발 (113)
      • mediapipe (16)
      • insightface (5)
      • JongjuAR (3)
    • 자료구조 알고리즘 (79)
      • 코딩테스트 (64)
      • 이론 (15)
    • 공부 (7)
      • 단행본 (7)
      • 튜토리얼 (19)
      • 논문 (15)
      • 복기 (5)
    • 참여 (5)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • speaker adaptation tts
  • 머신러닝이란
  • postgresql install in mac
  • postgresql 재설치
  • mediapipe translate
  • flutter 행사 후기
  • 플러터
  • google mediapipe
  • 컴퓨터 비전 책 추천
  • 구글 미디어파이프
  • ios google places api
  • 플러터 튜토리얼
  • flutter
  • 컴퓨터 비전
  • kubeflow설치안됨
  • 미디어파이프
  • flutter tutorial
  • mediapipe
  • flutter conference
  • python telegrambot
  • kubeflow설치가이드
  • 음성인식 기초
  • 음성인식 튜토리얼
  • torchscript vs onnx vs tensorrt
  • git tutorial
  • flutter 행사
  • 컴퓨터 비전 기초
  • vscode 스프링 설치
  • 깃 튜토리얼
  • 딥러닝 기반 음성인식 기초

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
내공얌냠
608. Tree Node
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.