We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Try DFS instead of BFS. You may also want to try and put in some optimizations so that you do not need to recacluate the sum of subtrees if you have already done so.
Cut the Tree
You are viewing a single comment's thread. Return to all comments →
Try DFS instead of BFS. You may also want to try and put in some optimizations so that you do not need to recacluate the sum of subtrees if you have already done so.
Let me know how that works for you.