| Conditions | 8 |
| Paths | 9 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function oddCells(int $m, int $n, array $indices): int |
||
| 10 | { |
||
| 11 | if ($m <= 0 || $n <= 0 || empty($indices)) { |
||
| 12 | return 0; |
||
| 13 | } |
||
| 14 | |||
| 15 | [$cnt, $row, $col] = [0, array_fill(0, $m, 0), array_fill(0, $n, 0)]; |
||
| 16 | foreach ($indices as $item) { |
||
| 17 | $row[$item[0]]++; |
||
| 18 | $col[$item[1]]++; |
||
| 19 | } |
||
| 20 | for ($i = 0; $i < $m; $i++) { |
||
| 21 | for ($j = 0; $j < $n; $j++) { |
||
| 22 | if (($row[$i] + $col[$j]) % 2 !== 0) { |
||
| 23 | $cnt++; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | return $cnt; |
||
| 29 | } |
||
| 50 |