Company: Swiggy_9dec
Difficulty: medium
Recursive Land Division body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", "Arial", sans-serif; line-height: 1.6; color: #333; max-width: 800px; margin: 20px auto; padding: 0 20px; } h1, h2 { border-bottom: 2px solid #eee; padding-bottom: 10px; } code { background-color: #f4f4f4; padding: 2px 6px; border-radius: 4px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; } pre { background-color: #f4f4f4; padding: 15px; border-radius: 5px; overflow-x: auto; } ul { padding-left: 20px; } li { margin-bottom: 10px; } Recursive Land Division Problem Description A country consists of N regions, each containing a specific number of towns. The government has decided to split the country into two separate nations in a way that minimizes the absolute difference between the total number of towns in each new nation. Each region is connected to another region through roads, forming a tree structure (i.e., an undirected conn