PS/LeetCode (2) 썸네일형 리스트형 [LeetCode 104] Maximum Depth of Binary Tree 문제 Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 이진 트리의 최대 깊이를 구하는 문제 풀이 # 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 import collections cl.. [leetcode125 Python] Valid Palindrome class Solution: def isPalindrome(self, s: str) -> bool: cleared = "" for content in s: if content.isalnum(): cleared += content cleared = cleared.lower() return cleared == cleared[::-1] isalnum() : alphabet(영어,한글)이거나 number(숫자)이면 True, 아니면(ex.특수문자, 공백) False lower() : 모두 소문자로 바꾸어 주는 메소드. 모두 대문자로 바꾸어 주는 메소드로는 upper()이 있다 이전 1 다음