Coupang | Staff SE | BLR
Summary
I recently had a phone screening interview with Coupang for a Staff Software Engineer position in Bangalore. The interview primarily focused on an algorithmic problem involving finding the distance between the two closest islands in a grid.
Full Experience
I am currently a Staff Software Engineer at Walmart with 6.5 years of experience. I recently went through a Phone Screening round for a Staff Software Engineer role with Coupang's Rocket Growth Team in Bangalore. The interview lasted 60 minutes and was centered around a specific data structures and algorithms problem.
Interview Questions (1)
Given a grid[][] containing 0s and 1s, where '0' represents water and '1' represents the land. Given that an island is a group of land (1s) surrounded by water (0s) on all sides.
The task is to find the distance between the two closest islands such that:
- Distance between two islands is the minimum number of '0' between two islands.
- Only 4 - directional movement is allowed.
- There are at least 2 islands present in the grid.
Input: grid =
{{1, 1, 0, 1, 1},
{1, 1, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 1, 1}}
Output: 1
Explanation: There are three islands present in the grid.
Nearest pair of islands have only 1 zero (bolded in input grid) in between them.
Input: grid =
{{1, 0, 0, 0, 1},
{1, 1, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 1, 1, 1}}
Output: 2
Explanation: There are three islands present in the grid.
Nearest pair of islands have 2 zeroes in between them (depicted by bold 0 in input grid).
In this case there are multiple pair of islands having a distance of 2 between them.