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 federation is made up of N provinces, each holding a certain number of villages. Central authorities have decided to split the federation into exactly two independent states so that the gap between the total villages held by each new state is as small as possible. Every province connects to at least one other province by road, and altogether these roads for