일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Regular Expression
- Convert Sorted List to Binary Search Tree
- 운영체제
- 파이썬
- data science
- Decorator
- 315. Count of Smaller Numbers After Self
- LeetCode
- iterator
- attribute
- Generator
- kaggle
- Protocol
- concurrency
- Class
- shiba
- DWG
- Python
- 컴퓨터의 구조
- 30. Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- 밴픽
- Python Code
- 715. Range Module
- Python Implementation
- t1
- 프로그래머스
- 43. Multiply Strings
- 시바견
- 109. Convert Sorted List to Binary Search Tree
Archives
- Today
- Total
Scribbling
LeetCode: 101. Symmetric Tree 본문
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
return self.isMirror(root.left, root.right)
def isMirror(self, left, right):
if left == None and right == None:
return True
if left == None or right == None:
return False
if left.val != right.val:
return False
return self.isMirror(left.left, right.right) and \
self.isMirror(left.right, right.left)
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 171. Excel Sheet Column Number (0) | 2021.12.20 |
---|---|
LeetCode: 125. Valid Palindrome (0) | 2021.12.20 |
LeetCode: 236. Lowest Common Ancestor of a Binary Tree (0) | 2021.12.15 |
LeetCode: 230. Kth Smallest Element in a BST (0) | 2021.12.14 |
LeetCode: 968. Binary Tree Cameras (0) | 2021.12.13 |