You are provided a series of aerial-view pictures of the same coastal region, taken a few minutes apart. Each picture consists of an n x n binary grid, where 0 represents land (above water) and 1 represents water (below water).
- The tide appears from the left and rises toward the right, so in each row, all
1s will be before all0s. - Once a region is under water, it stays under water.
- All pictures are different.
Determine which picture shows the most even balance between land and water (i.e., where the number of 1s most closely equals the number of 0s). In the event of a tie, return the earliest picture.
Input: An array of n x n grids.
Visualization for grid is not implemented for this step data.
pictures_count=5
target=4.5
Step 1 / 4
Step 1:
Pictures are sorted by time (water increases). Binary search for 50% water.
Focus: default
pictures_count=5target=4.5