old_map and new_map. In each, 1 is land and 0 is water. An island is a group of land cells joined through their sides (up, down, left, right); everything beyond the edge is water.
An island of the new map is nested if every one of its cells is land on the old map as well.
Return the number of nested islands on new_map.old_map=[[1, 1, 0], [0, 1, 0], [1, 0, 1]], new_map=[[1, 1, 0], [0, 0, 0], [1, 1, 1]] → 1
The new map has two islands. The top one, {(0, 0), (0, 1)}, lies entirely on old land. The bottom one, {(2, 0), (2, 1), (2, 2)}, touches (2, 1), which is water on the old map. The answer is 1.
old_map=[[1, 1], [1, 1]], new_map=[[1, 0], [0, 1]] → 2
Two diagonal cells are two separate islands, and both sit on old land.
old_map=[[0, 1]], new_map=[[1, 1]] → 0
old_map=[[1, 1, 0], [0, 1, 0], [1, 0, 1]], new_map=[[1, 1, 0], [0, 0, 0], [1, 1, 1]]
1
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.