<p>Given an <code>m x n</code> 2D binary grid <code>grid</code> which represents a map of <code>'1'</code>s (land) and <code>'0'</code>s (water), return <em>the number of islands</em>.</p> <p>An <strong>island</strong> is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.</p> <p> </p> <p><strong>Example 1:</strong></p> <pre> <strong>Input:</strong> grid = [ ["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0","0","0"], ["0","0","0","0","0"] ] <strong>Output:</strong> 1 </pre> <p><strong>Example 2:</strong></p> <pre> <strong>Input:</strong> grid = [ ["1","1","0","0","0"], ["1","1","0","0","0"], ["0","0","1","0","0"], ["0","0","0","1","1"] ] <strong>Output:</strong> 3 </pre> <p> </p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == grid.length</code></li> <li><code>n == grid[i].length</code></li> <li><code>1 <= m, n <= 300</code></li> <li><code>grid[i][j]</code> is <code>'0'</code> or <code>'1'</code>.</li> </ul>