<?php
/**
* @param Integer[][] $grid
* @return Integer
*/
function findMaxFish($grid) {
...
...
...
/**
* go to ./solution.php
*/
}
/**
* Helper function for DFS
* @param $r
* @param $c
* @param $grid
* @param $visited
* @param $rows
* @param $cols
* @param $directions
* @return array|bool|int|int[]|mixed|null
*/
function dfs($r, $c, &$grid, &$visited, $rows, $cols, $directions) {
...
...
...
/**
* go to ./solution.php
*/
}
// Example 1
grid = [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]];
echo getMaxFish($grid); // Output: 7
// Example 2
$grid = [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]];
echo getMaxFish($grid); // Output: 1
?>
로그인 후 복사