Tap here to switch tabs
Problem
Submissions

Problem: Bomb Enemy

Try to solve the Bomb Enemy problem.

Statement

Given an mimesnm imes n grid grid of characters, each cell is defined as follows:

  • 'W' represents a wall.

  • 'E' represents an enemy.

  • '0' represents an empty cell.

Return the maximum number of enemies you can destroy by placing one bomb in an empty cell.

When a bomb is placed in an empty cell, it destroys all enemies in the same row and column extending in all four directions up to the edge of the grid or until blocked by a wall, because walls cannot be destroyed.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤m,n≤5001 \leq m, n \leq 500

  • grid[i][j] is either 'W', 'E', or '0'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Bomb Enemy

Try to solve the Bomb Enemy problem.

Statement

Given an mimesnm imes n grid grid of characters, each cell is defined as follows:

  • 'W' represents a wall.

  • 'E' represents an enemy.

  • '0' represents an empty cell.

Return the maximum number of enemies you can destroy by placing one bomb in an empty cell.

When a bomb is placed in an empty cell, it destroys all enemies in the same row and column extending in all four directions up to the edge of the grid or until blocked by a wall, because walls cannot be destroyed.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤m,n≤5001 \leq m, n \leq 500

  • grid[i][j] is either 'W', 'E', or '0'.