Company: Swiggy_9_jan
Difficulty: medium
Recursive Land Division 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 connected graph with N-1 edges and no cycles). Your task is to determine the minimum possible absolute difference in the number of towns between the two new nations after removing exactly one road. Function Description You must implement the following function minTownDifference . Parameters int N → The number of regions. int[] towns → An array of size N, where towns[i] represents the number of towns in the (i+1)th region. int[][] roads → A list of N-1 tuples, where each tuple (u, v) represents a bidirectional road connecting region u and region v . Retur