public int numIslands(boolean[][] grid) {
        // Write your code here
        int count = 0;
        for (int i = 0; i < grid.length; ++i) {
            for (int j = 0; j < grid[0].length; ++j) {
                if (grid[i][j] == true) {
                    count += 1;
                    dfs(grid, i, j);
                }
            }
        }
        return count;
    }