Given a grid where 0 is land and 1 is water, return the number of closed islands — groups of land (connected 4-directionally) that are completely surrounded by water and do not touch the grid border. The input is JSON {grid}.
Input: JSON {grid}.
Output: Integer — the number of closed islands.
Input: {"grid":[[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]}
Output: 2
Explanation: Two enclosed land regions.Input: {"grid":[[0]]}
Output: 0
Explanation: Border land is not closed.Input: {"grid":[[1,1,1],[1,0,1],[1,1,1]]}
Output: 1
Explanation: One enclosed cell.1<=rows,cols<=1000 land, 1 water