public int numIslands(char[][] grid) {
		int n = grid.length;
		if (n == 0)
			return 0;
		int m = grid[0].length;
		if (m == 0)
			return 0;
		int ret = 0;
		int[][] visited = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (grid[i][j] == '1' && visited[i][j] == 0) {
					ret++;
					dfs(grid, visited, i, j, n, m);
				}
			}
		}
		return ret;
	}