Kingdom Partition

Unable to clear test cases give some sample test case which can fail.

code link: https://ide.codingblocks.com/s/233104