361 Bomb Enemy
Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero),
return the maximum enemies you can kill using one bomb.
The bomb kills all the enemies in the same row and column from the planted point
until it hits the wall since the wall is too strong to be destroyed.
Note that you can only put the bomb at an empty cell.
Example:
For the given grid
0 E 0 0
E 0 W E
0 E 0 0
return 3. (Placing a bomb at (1,1) kills 3 enemies)
@tag-dp

Algorithm

Create four cumulative arrays v1, v2, v3, v4,

v1 is the cumulative array from left to right in the horizontal direction

v2 is the cumulative array from right to left in the horizontal direction

v3 is the cumulative array from top to bottom in the vertical direction

v4 is the cumulative array from bottom to top in the vertical direction

After building this cumulative array, for any position (i, j), the maximum number of enemies that can be killed is v1[i][j] + v2[i][j] + v3[i][j] + v4[i][j], finally by comparing the cumulative sum of each position, you can get the result.