New
ML System Design & SQL tracks just landed
See what's new
×
Question Bank
Pricing
Blog
Forum
HOT
Referral
Description
Solution
Discussion
Submissions
Ask AI
Question Bank
Uber
Coding Question
AI Insights
Quick Summary
Find a root node in a directed tree that minimizes the number of edge reversals required to make all edges point away from it.
The input guarantees a tree structure with exactly n-1 directed edges connecting n nodes.
Evaluate every possible root choice and return the smallest reversal count.
What This Tests
Tree and graph traversal techniques
Rerooting dynamic programming concept
State propagation and incremental cost updates
Transforming directed graphs into weighted structures
Common Patterns
Graph Traversal
DFS/BFS
Dynamic Programming
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Qwen
Qwen3.6-Flash
0/2000
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected