| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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
													
											
												
												- 개발자
 - 사이드
 - Daily Challenge
 - 만화도
 - realclass
 - 프로젝트
 - 뭐든
 - 잡생각
 - 읽기
 - leetcode
 - 영어공부
 - 월간
 - 매일
 - 화상영어
 - 쓰릴오브파이트
 - 10분
 - 스탭퍼
 - 괜찮음
 - 리얼 클래스
 - English
 - FIT XR
 - 30분
 - 미드시청
 - 파비최
 - 영어원서읽기
 - Writing
 - 3줄정리
 - Problem Solving
 - 링피트
 - 운동
 
													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