arnab2001 / DSA

Collection of DSA problems and solutions
38 stars 186 forks source link

Create Finding a Centroid.cpp #372

Open 4d4r5h opened 2 years ago

4d4r5h commented 2 years ago

Given a tree of n nodes, our task is to find a centroid, i.e., a node such that when it is appointed the root of the tree, each subtree has at most ⌊n/2⌋ nodes.

Finding a Centroid (CSES)