Bomb Enemy Best Coordinates
Updated
Problem statement
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]]The center-left empty cell reaches three enemies.
Example 2
grid = ["0"]return = [[0,0]]The only empty cell is the maximum even though it kills zero.
Example 3
grid = ["EEE"]return = []There is no legal bomb cell.
Constraints
1 <= rows, columns <= 500.- The grid is rectangular and contains only
E,W, and0.
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