Minimum Flood Level to Disconnect a Grid
Updated
Problem statement
An elevation grid has a start at its top-left cell and a destination at its bottom-right cell. At integer water level L, every cell with elevation at most L is flooded and unavailable. A route can move one cell up, down, left, or right, and may use only unflooded cells.
Find the smallest nonnegative water level for which no route remains from start to destination. Flooding either endpoint also removes every route. Water rises to the stated level inclusively: a cell of elevation L is already flooded at level L.
Function
minimumFloodLevel(elevation: int[][]) → intExamples
Example 1
elevation = [[5,4],[3,6]]return = 4At level 3, the route through elevation 4 remains. At level 4, both possible routes are cut.
Example 2
elevation = [[8,2,7],[6,5,4],[3,9,10]]return = 5The strongest remaining route runs through elevations 8, 6, 5, 9, and 10. Flooding level 5 cuts it.
Example 3
elevation = [[0,9],[8,10]]return = 0The start is flooded at the first allowed water level, 0.
Constraints
1 <= elevation.length, elevation[r].length <= 40; all rows have equal length.0 <= elevation[r][c] <= 1000000. Equal elevations are allowed.- Return an integer from
0through the maximum cell elevation.
More Meta Onsite Interview questions
- Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
- Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
- Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
- Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
- Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
- Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026
Similar questions at other companies
- Maximum Safeness of a Grid PathIntuit · OAIntuit interview questions
- Avoiding the Obstacles (IMC Sydney 🦪)IMC Trading · OAIMC Trading interview questions
- Course ScheduleByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
- Course SchedulePlaud · ONSITE INTERVIEW
- Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Nearest Charging Station on a GridSpotify · ONSITE INTERVIEW
- Hierarchical Permission CheckeBay · ONSITE INTERVIEWeBay interview questions
- Shortest Path Node Count Avoiding Broken NodesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
Meta interview experiences
- Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
- Meta Business Support Engineer Phone Screen: 1 Experience
- Meta Software Engineer Onsite Questions: 3 Experiences
- Meta AI Native Engineer OA and Onsite: 1 Experience
- Meta AI-Native Coding Interview: 3 Experiences
- Meta Production Engineer Intern Questions: 6 Experiences