HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
👻
개발 기록
/
코딩테스트 스터디
코딩테스트 스터디
/
Range Sum of BST

Range Sum of BST

Link
https://leetcode.com/problems/range-sum-of-bst/
Deadline
Dec 14, 2021
Status
Archived
Type
DFS
Binary Search

문제

notion image
notion image

풀이

효성
백트래킹, dfs에 가까움
var rangeSumBST = function(root, low, high) { let sum = 0; const bfs = (root) => { if(root === null) return; if(root.val >= low && root.val <= high) { sum += root.val; } bfs(root.left); bfs(root.right); } bfs(root); return sum; };