Facebook | Phone | Missing Ranges & Making a Large Island

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-11-01Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e5
Interview Stage: Phone Screen
Location: New York
Year: unknown

Original Post Content:

Position: E5
Location: New York

First EASY, a variation of https://leetcode.com/problems/missing-ranges/

Second, HARD, exactly this one : https://leetcode.com/problems/making-a-large-island/

"Given a Matrix NxM, find the largest island if you convert one water cell to land"
0 = Water
1 = Land
Example:
[[1, 0, 1],
[0, 1, 0],
[1, 1, 1]]

Answer is 7

I answered both, first one in less than 5 min, the second one took me a good 30 minutes, where I used a Union Find approach. (FYI, my solution has 114 lines... that's insane)

Update: add the LC link for the second question

Comments