Given a grid of 1s (land) and 0s (water), return the number of land cells from which you cannot walk off the boundary of the grid in any number of 4-directional moves (land cells not connected to the border). The input is JSON {grid}.
Input: JSON {grid}.
Output: Integer — the count of enclosed land cells.
Input: {"grid":[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]}
Output: 3
Explanation: Three cells cannot reach the border.Input: {"grid":[[1]]}
Output: 0
Explanation: Border cell escapes.Input: {"grid":[[0,0],[0,0]]}
Output: 0
Explanation: No land.1<=rows,cols<=500