Largest non-contiguous size in 2-d array | Amazon Coding assessment | SDE L4
Anonymous User
291

This question was asked by Amazon Coding assessment
Location San francisco

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
[ [0, 1, 2, 3],
[1, 2, 1, 0],
[1, 5, 6, 1],
[1, 8, 3, 4] ]

Answer is 3 (for the integer 1)

[ [ 1, 0, 12, 1 ],
[ 7, 3, 2, 5 ],
[ -5, 2, 2, -9 ] ]

Answer is 3 (for the integer 2)

[ [ 5, 5, 5]
[5, 2, 5 ]
[5, 5, 5 ] ]

Answer is 8 (for the integer 5)

Comments (1)