| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- 영어원서읽기
- 잡생각
- 사이드
- 운동
- 쓰릴오브파이트
- 만화도
- Writing
- FIT XR
- 3줄정리
- 개발자
- 뭐든
- Problem Solving
- 미드시청
- 스탭퍼
- 프로젝트
- 읽기
- realclass
- 10분
- Daily Challenge
- 월간
- 링피트
- 괜찮음
- leetcode
- English
- 화상영어
- 매일
- 30분
- 영어공부
- 리얼 클래스
- 파비최
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/construct-string-from-binary-tree/
Construct String from Binary Tree - 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
오늘도 트리 문제. Easy 난이도인데 쉬운지는 잘 모르겄다 =_=;
class Solution:
def tree2str(self, root: Optional[TreeNode]) -> str:
if not root:
return ''
output = str(root.val)
if root.left or root.right:
output += '(' + self.tree2str(root.left) + ')'
if root.right:
output += '(' + self.tree2str(root.right) + ')'
return output반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.09.09 |
|---|---|
| Today's Challenge (0) | 2022.09.08 |
| Today's Challenge (0) | 2022.09.06 |
| Today's Challenge (0) | 2022.09.05 |
| Today's Challenge (0) | 2022.09.04 |
Comments