There is a well known centroid decomposition problem for finding the number of ‘k’ length path in a tree.
Just a simple modification is needed. Need to use a fast data structure like fenwick tree or segment tree to find the the path less than or equal to ‘k’.

Statistics

100% Solution Ratio
YouKnowWhoEarliest, Aug '21
Kuddus.6068Fastest, 0.4s
YouKnowWhoLightest, 14 MB
NirjhorShortest, 1722B
Toph uses cookies. By continuing you agree to our Cookie Policy.