220617 금 Algorithms TIL

bongf·2022년 6월 17일
0

알고리즘TIL

목록 보기
138/153

리트코드 104. Maximum Depth of Binary Tree Easy

def maxDepth(root):
	if root is None:
    	return 0
        
    depth = 0
    queue = collections.deque([root])
    while queue:
    	depth += 1
        for _ in range(len(queue)):
        	cur = queue.popleft()
            if cur.left:
            	queue.append(cur.left)
            if cur.right:
            	queue.append(cur.right)
     return depth 

리트코드 543. Diameter of Binary Tree Easy

프로그래머스 줄서는 방법 lev2

  • 팩토리얼을 쓰는 문제
  • 나머지가 0일 때 reverse() 해 주는 부분을 놓쳤다
  • 문제
  • 풀이
profile
spring, java학습

0개의 댓글