Intuitive JavaScript solution using DFS
Approach\n Describe your approach to solving the problem. \nDFS\n\n# Complexity\n- Time complexity: O(M * N)\n Add your time complexity here, e.g. O(n) \n\n- Sp
# Approach\n<!-- Describe your approach to solving the problem. -->\nDFS\n\n# Complexity\n- Time complexity: O(M * N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(M * N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar findMaxFish = function(grid) {\n    let max_fishes = 0;\n    let ROW = grid.length;\n    let COL = grid[0].length;\n    \n    // returns the sum of fishes possible\n    const DFS = (r, c, visit) => {\n        \n        // base cases returns 0; \n        if( r < 0 || r >= ROW ||\n            c < 0 || c >= COL || \n            visit.has(`${r}_${c}`) ||\n            grid[r][c] == 0 \n          ){\n            return 0;\n        }\n        \n        // set visted\n        visit.add(`${r}_${c}`);\n        \n        let sum = grid[r][c]; // add current value to sum\n        \n        // check the surrounding nodes\n        sum += DFS(r, c + 1, visit);\n        sum += DFS(r, c - 1, visit);\n        sum += DFS(r + 1, c, visit);\n        sum += DFS(r - 1, c, visit);\n        \n        return sum;\n    }\n    \n    let set = new Set(); // to record all visted nodes\n    \n    // go through each cell\n    for(let r = 0; r < ROW; r++){\n       for(let c = 0; c < COL; c++){\n            // if the cell is water\n           if(grid[r][c] != 0){ \n               let res = DFS(r, c, set);\n\n               //compare the result from DFS to main global variable \n               max_fishes = Math.max(res, max_fishes);\n           }\n       }\n    }\n    \n    return max_fishes; \n};\n```
['Depth-First Search', 'JavaScript']