Skip to content

Conversation

@jungmyunggi
Copy link
Collaborator

문제

Type Info
Time Complexity O(n)
Space Complexity O(n)
Algorithm dfs
Data Structure x

Constraints

  • The number of nodes in the tree is in the range [0, 5000].
  • -1000 <= Node.val <= 1000
  • -1000 <= targetSum <= 1000

Edge Case

x

풀이

if(root가 없으면) return false
if(리프노드이면) return 노드의 값 === targetSum

return 재귀(왼쪽노드, targetSum - 노드의 값) || 재귀(오른쪽노드, targetSum - 노드의 값)

어려웠던 점

  • 재귀를 평소에 사용하지 않아서 구현하는데 어려웠음

알게된 점

x

Copy link
Member

@BangDori BangDori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jungmyunggi jungmyunggi merged commit a153b9a into main Jan 2, 2025
2 checks passed
@BangDori BangDori deleted the jungmyunggi/path-sum branch January 10, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants