Some parts of farmer John's lands are swampy. These swampy regions are rectangles with horizontal and vertical sides. Your task is to find the total area of all the non-swampy regions that are surrounded completely by swampy lands. A non-swampy region is surrounded if it is not possible to leave the farm from anywhere on this region, without passing through some point of a swampy piece of land. The corners and edges of a swampy piece of land are considered to be swampy as well. See examples for further clarifications.
You are given a String[] swampy. The ith element of swampy is a space-delimited list of four integers in the form "x1 y1 x2 y2" (quotes for clarity only) where (x1, y1) and (x2, y2) are the opposite corners of the ith rectangular piece of swampy land. Return the total area of all the non-swampy regions that are surrounded by swampy lands.
|