amazon logo
Amazon· SDE L4

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

Location
san francisco
Posted
16 Jul 2021
257 reads

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.

How it went

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.

Questions asked (1)

  1. 01

    Largest Non-Contiguous Size in 2D Array

    Data Structures & Algorithms · Medium

    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)

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!