Leetcode 305. Number of Islands II
Given an initially all-water m×n grid, process a sequence of add-land operations and return the number of islands (4-directionally connected land components) after each addition. The problem requires maintaining dynamic connectivity efficiently—typically via Union-Find (disjoint set) with handling for duplicate adds and frequent merges.
Asked at:
Uber
Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late March, 2026
Uber
Senior
The question was not esactly in the same wordings. create an data-structure that supports the following operations. addLand(x, y) - marks (x,y) as an land isLand(x, y) - returns True if (x,y) is a land else False extension 1: add a functionality : getIslands() - returns the number of inlands that we have. (x,y) are 4-directionally connected extension 2: add one more function: addBridge(location1, location2) - location1 and location2 are two different land points. addBridge connects these two points. (Note : we are not asked to find the bridge i.e adding land masses to connect these two it should simple connect these two points.)
Mid February, 2026
Uber
Senior
Variation of this question where there would be openRestaurant() and findTotalOpenRestaurantBlocks()
Mid January, 2026
Microsoft
Senior
Hello Interview Premium
Your account is free and you can post anonymously if you choose.