FastPrepBomb Enemy Best Coordinates
Problems/Bomb Enemy Best Coordinates

Bomb Enemy Best Coordinates

SambaNova Systems logoSambaNova Systems● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand SambaNova onsite report dated June 30, 2022 describes a variant of the well-known Bomb Enemy problem. It asks for the coordinates that reach the maximum, not only the count. Our version is about 96% the same as the reported question.

A grid contains enemies E, walls W, and empty cells 0. A bomb may be placed in one empty cell and kills every enemy in the same row and column until a wall blocks the direction.

Return every zero-based coordinate [row, column] that achieves the maximum kill count, ordered by row and then column. If there is no empty cell, return an empty array. Cells with a maximum of zero are still returned.

Function

bestBombCells(grid: String[]) → int[][]

Examples

Example 1

grid = ["0E00","E0WE","0E00"]return = [[1,1]]
grid
012300E001E0WE20E00
→
return
01011

The center-left empty cell reaches three enemies.

Example 2

grid = ["0"]return = [[0,0]]
grid
000
→
return
01000

The only empty cell is the maximum even though it kills zero.

Example 3

grid = ["EEE"]return = []
grid
0120EEE

There is no legal bomb cell.

Constraints

  • 1 <= rows, columns <= 500.
  • The grid is rectangular and contains only E, W, and 0.

More SambaNova Systems Onsite Interview questions

  • Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
  • 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
  • Sum Nodes with an Even-Valued GrandparentONSITE INTERVIEW · Seen Jun 2022
  • Validate Binary Search TreeONSITE INTERVIEW · Seen Jun 2022
  • Deterministic Zigzag SortPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Maximum Area of IslandONSITE INTERVIEW · Seen Jun 2022
  • Task Scheduler with CooldownPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Point Inside a TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Parse Variable, Expression, and Application TreesPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Flip Equivalent Binary TreesONSITE INTERVIEW · Seen Oct 2021

Similar questions at other companies

  • Maximal SquareAmazon · ONSITE INTERVIEW
  • Maximum All-Ones Square Side LengthOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Minimum Path SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Minimum Path SumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Largest Square of Ones in a GridExpedia · ONSITE INTERVIEWExpedia interview questions
  • Longest Increasing Path in a MatrixNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Longest Increasing Path in a MatrixVisa · ONSITE INTERVIEWVisa interview questions
  • Maximal Rectangle in a Binary MatrixGoogle · ONSITE INTERVIEWGoogle interview questions
  • Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions
  • Largest Square of OnesOpenAI · OAOpenAI interview questions
All SambaNova Systems interview questionsSee SambaNova Systems hiring insights
Saved
class Solution {
    public int[][] bestBombCells(String[] grid) {
        // write your code here
    }
}
Checking account…