Maximum Area of Island
Updated
Problem statement
Given a rectangular binary matrix grid, return the maximum area of an island. An island is a maximal group of cells containing 1 connected horizontally or vertically. Its area is its number of cells.
Return 0 when the matrix contains no land.
Function
maxIslandArea(grid: int[][]) → intExamples
Example 1
grid = [[0,0,1,0],[1,1,1,0],[0,1,0,1]]return = 5The center island contains five orthogonally connected land cells. The bottom-right cell is a separate island of area 1.
Example 2
grid = [[0,0],[0,0]]return = 0There are no land cells.
Constraints
1 <= grid.length, grid[i].length <= 300.- Every row has the same length.
grid[i][j]is either0or1.
More SambaNova Systems Onsite Interview questions
- Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
- 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
- Bomb Enemy Best CoordinatesONSITE 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
- 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
- Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
- Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
- Max Area of IslandGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Max Area of IslandRoku · ONSITE INTERVIEWRoku interview questions
- Max Area of IslandBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
- Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
- Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN
- Maximum Area of IslandSkydio · PHONE SCREENSkydio interview questions
- Number of IslandsIntuit · ONSITE INTERVIEWIntuit interview questions