Company: IBM_15june
Difficulty: medium
Maximum Power Block Problem Description A solar farm arranges its panels in a rectangular grid. Each panel produces a fixed non-zero amount of electricity, but a storm has knocked out several panels entirely — those spots are marked 0 and generate nothing. Panels that are still working can pool their output only with a working neighbor directly above, below, left, or right of them; diagonal neighbors don't count. Any set of working panels linked this way forms a single power block. Because of a safety limit, the plant can only draw current from one such block at a time. Given the grid, write a program that reports the largest total output obtainable from any single power block. Examples Example 1: Input: grid = [ [1, 2, 0, 0], [0, 3, 0, 4], [5, 0, 0, 4], [0, 0, 6, 4] ] Output: 18 Explanation: Block 1: [1, 2] → sum = 3 Block 2: [3] → sum = 3 Block 3: [4, 4, 6] (connected through right-down paths) → sum = 18 Block 4: [5] → sum = 5 Comparing all four blocks, the larges