Tap here to switch tabs
Problem
Submissions

Problem: Bomb Enemy

Bomb Enemy gives you a grid of walls, enemies, and empty cells. Place one bomb in an empty cell and return the greatest number of enemies it can destroy along unobstructed rows and columns.

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

Bomb Enemy gives you a grid of walls, enemies, and empty cells. Place one bomb in an empty cell and return the greatest number of enemies it can destroy along unobstructed rows and columns.

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'.