Largest non-contiguous size in 2-d array | Amazon Coding assessment | SDE L4
Summary
I recently completed a coding assessment for an Amazon SDE L4 position in San Francisco, which featured a challenging algorithmic problem focused on finding the largest non-contiguous area for a specific integer in a 2D array.
Full Experience
I participated in a coding assessment for Amazon for an SDE L4 role, located in San Francisco. The assessment primarily focused on a single, complex algorithmic question. I found the problem statement quite detailed, including several examples to clarify the 'largest non-contiguous size' concept. It required careful parsing of the rules for movement and area calculation within a 2D grid.
Interview Questions (1)
Given a 2-d array of integers, find the largest non-contiguous size or largest area.
Integers can move in four directions, up, down, left, and right.
Grid can contain any integer number.
If two different integers have the same biggest size, return any first.
Example 1:
[ [0, 1, 2, 3],
[1, 2, 1, 0],
[1, 5, 6, 1],
[1, 8, 3, 4] ]
Answer is 3 (for the integer 1)
Example 2:
[ [ 1, 0, 12, 1 ],
[ 7, 3, 2, 5 ],
[ -5, 2, 2, -9 ] ]
Answer is 3 (for the integer 2)
Example 3:
[ [ 5, 5, 5]
[5, 2, 5 ]
[5, 5, 5 ] ]
Answer is 8 (for the integer 5)