Largest Island After One Land Conversion
Updated
Problem statement
Given a rectangular binary grid, you may change at most one 0 into 1. An island is a four-directionally connected group of ones. Return the largest island area obtainable after the optional conversion.
Function
largestIsland(grid: int[][]) → intExamples
Example 1
grid = [[1,0],[0,1]]return = 3Converting either zero joins both diagonal land cells through the converted cell.
Example 2
grid = [[1,1],[1,0]]return = 4Converting the only zero makes the complete grid one island.
Constraints
1 <= grid.length, grid[i].length <= 500grid[i][j] is 0 or 1four-directional adjacency defines an island
More Amazon Onsite Interview questions
- Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dungeon GameONSITE INTERVIEW · Seen Nov 2026
- Integer BreakONSITE INTERVIEW · Seen Nov 2026
- LFU CacheONSITE INTERVIEW · Seen Nov 2026
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
- First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Largest Island After One Land ConversionGoogle · ONSITE INTERVIEWGoogle interview questions
- Making a Large IslandMeta · ONSITE INTERVIEWMeta interview questions
- Largest Island After One Land ConversionBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Evaluate DivisionPlaud · ONSITE INTERVIEW
- Count Friend CirclesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Redundant ConnectionMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Connected Components in an Undirected GraphNutanix · ONSITE INTERVIEWNutanix interview questions
- Connected GroupsFivetran · ONSITE INTERVIEWFivetran interview questions
- Evaluate DivisionApple · PHONE SCREENApple interview questions
- Minimum Unreachable WarehousesVisa · OAVisa interview questions
Amazon interview experiences
- Amazon SWE OA with AI Coding: 1 Experience
- Amazon SWE Intern Phone Screen Interview Experience: 1 Experience
- Amazon New Grad SDE I OA and Virtual Onsite: 1 Experience
- Amazon BIE Intern SQL and Interview Questions: 17 Experiences
- Amazon Experienced SWE AI-Assisted Debugging OA: 1 Experience
- Amazon SDE II (L5) Interview Questions: 5 Experiences