[LeetCode][Python3] 104. Maximum Depth of Binary Tree
2018. 9. 27. 00:32 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/maximum-depth-of-binary-tree/description/
My Solution :
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 155. Min Stack (0) | 2018.09.28 |
---|---|
[LeetCode][Python3] 141. Linked List Cycle (0) | 2018.09.28 |
[LeetCode][Python3] 136. Single Number (0) | 2018.09.27 |
[LeetCode][Python3] 121. Best Time to Buy and Sell Stock (0) | 2018.09.27 |
[LeetCode][Python3] 101. Symmetric Tree (0) | 2018.09.27 |
[LeetCode][Python3] 100. Same Tree (0) | 2018.09.26 |
[LeetCode][Python3] 70. Climbing Stairs (0) | 2018.09.26 |
[LeetCode][Python3] 3. Longest Substring Without Repeating Characters (0) | 2018.09.24 |
최근에 달린 댓글 최근에 달린 댓글