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.
Rust solution - work in progress here. The solution so far produces correct results, but has TLE's and is in need of some optimization. I'm looking at compressing the sparse branches while preserving the ability to calculate node values on the fly.
Things I wish the problem description had told me:
The end points of the edges in the input data can be in either order.
May need to traverse tree starting at root to fix parent child relationships.
The queries can involve finding common ancestor.
Update values with +=: .value += v + d * k;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Rooted Tree
You are viewing a single comment's thread. Return to all comments →
Rust solution - work in progress here. The solution so far produces correct results, but has TLE's and is in need of some optimization. I'm looking at compressing the sparse branches while preserving the ability to calculate node values on the fly.
Things I wish the problem description had told me:
+=
:.value += v + d * k;