[LeetCode 풀이/python] 113. Path Sum II (medium)
문제 설명: 이진트리 root 와 정수 targetSum 이 주어졌을 때, 루트에서 단말 노드까지의 경로에 있는 모든 수의 합이 targetSum 과 같아지는 경로를 모두 리턴하시오. 단말 노드는 자식 노드를 갖지 않는 노드를 가리킴. (Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where each path's sum equals targetSum. A leaf is a node with no children.) 예시 1) 입력: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22 --> 출력: [[5,4,11,2],[5,8,4,5]..
2021. 3. 10.
[LeetCode 풀이/python] 101. Symmetric Tree (easy)
문제 설명: 이진트리 root 가 주어졌을 때, 해당 트리가 자기 자신의 거울인지 (i.e. 중심을 기준으로 대칭인지) 확인하시오. (Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).) 예시 1) 입력: root = [1, 2, 2, 3, 4, 4, 3] --> 출력: true 예시 2) 입력: root = [1, 2, 2, null, 3, null, 3] --> 출력: false 제한 조건: 트리의 노드 개수는 [1, 1000] 의 범위 내에 있음 -100 bool: if not root: return False else: return self.check_sy..
2021. 3. 10.