Company: IBM_14sep
Difficulty: medium
Question 19 Problem Description In the city of Electropolis, power is drawn from a network of energy cells laid out in a rectangular grid. Each cell in this grid stores a certain amount of electricity represented by a non-zero integer. Due to a massive short-circuit, several parts of the grid have failed — these are now marked with a 0 and are considered dead cells. The remaining live cells can only share their power with neighboring cells in the up, down, left, and right directions. Diagonal connections are not allowed. A group of such connected live cells forms a power block. The engineers must now determine how much power can still be delivered to Electropolis. But here's the twist — the city can only draw electricity from one connected power block at a time due to safety regulations. Write a program that takes a 2-D grid as an input and returns an integer representing the maximum amount of energy that can be given to city. Examples Example 1: Input: grid = [1, 2, 0, 0], [0, 3, 0, 4