儒猿課堂大型訂單系統(tǒng)架構(gòu)演進(jìn)項目實戰(zhàn)
if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) {
? ? ? ? ? ?return;
? ? ? ?}
? ? ? ?// marked
? ? ? ?int m = matrix.length;
? ? ? ?int n = matrix[0].length;
? ? ? ?boolean[][] visited = new boolean[m][n];
? ? ? ?int connectComponentCount = 0;
? ? ? ?// traversal
? ? ? ?for (int i = 0; i < m; i++) {
? ? ? ? ? ?for (int j = 0; j < n; j++) {
? ? ? ? ? ? ? ?if (specialCondition && !visited[i][j]) {
? ? ? ? ? ? ? ? ? ?bfs(matrix, visited, i, j);
? ? ? ? ? ? ? ? ? ?connectComponentCount++;
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
標(biāo)簽: