Definition at line 5 of file main.cpp.
◆ countServers()
| int Solution::countServers |
( |
vector< vector< int > > & |
grid | ) |
|
|
inline |
Definition at line 8 of file main.cpp.
9 {
10 vector<int> row_count(grid.size(), 0);
11 vector<int> col_count(grid[0].size(), 0);
12 for (int i = 0; i < (int)grid.size(); ++i)
13 {
14 for (int j = 0; j < (int)grid[0].size(); ++j)
15 {
16 if (grid[i][j] == 1)
17 {
18 row_count[i]++;
19 col_count[j]++;
20 }
21 }
22 }
23 int counter = 0;
24 for (int i = 0; i < (int)grid.size(); ++i)
25 {
26 for (int j = 0; j < (int)grid[0].size(); ++j)
27 {
28 if (grid[i][j] == 1 && (row_count[i] > 1 || col_count[j] > 1))
29 counter++;
30 }
31 }
32 return counter;
33 }
Referenced by main().
The documentation for this class was generated from the following file: