Go Interview with an Amazon engineer.

Go Interview with an Amazon engineer

Interview Summary

Problem type

Unique Shapes in a Matrix

Interview question

Find the number of unique shapes inside a grid of matrix. A shape is denoted by a grouping of 1s from above, under, left, and right.

Example:

0 0 0 1
1 1 0 1
0 1 0 0
1 0 0 1
1 0 0 1

Total number of unique shapes - 2

Interview Feedback

Feedback about Full Metal Slide Rule (the interviewee)

Advance this person to the next round? Yes

How were their technical skills? 4/4

How was their problem solving ability? 3/4

What about their communication ability? 4/4

Strengths

Areas of Improvements

Advice for future interviews

Interview Transcript

Digital Avenger: Hi. So before we get started, do you mind if I ask you one or two questions that sort of help me calibrate the interview properly?
Full Metal Slide Rule: Okay. I don't have any questions. Okay, go ahead.
Digital Avenger: Mainly the question is around, like, do you have any interviews lined up and which company, how long, basically from now. Is there anything specific that you're looking from this interview practice?
Full Metal Slide Rule: Yeah, I will have an interview, formal interview in coming weeks. So before that I want to have some practice. So what's the content of practice? I think mostly on algorithm, but whatever is related to the interview process, I'm just glad to practice and let someone else to help me.
Digital Avenger: Okay, got it. Can I ask which company the interview is for?
Full Metal Slide Rule: So I'm going to interview for mental.
Digital Avenger: Okay. At e six. Full Metal Slide Rule: I just senior engineer.
Digital Avenger: Okay, got it. Sure. Okay, that makes sense. In the spirit of full disclosure, I am a wire at Amazon, so the process may not be exactly the same. Most of the things, in my opinion, will be the same. How they ask questions, what they judge. So basically, e three and e four, that's the one and two levels. I think the questions have the same more or less judgment criteria.

Formal Understanding of Problem and Solution

When identifying the unique shapes, the key approach is to check all 1s within the matrix, treating connected 1s as belonging to the same shape, either vertically or horizontally connected.

Detailed Steps

  1. Identify connected components of 1s.
  2. Use Depth First Search (DFS) or Breadth First Search (BFS) to explore each shape.
  3. Store and deduplicate found shapes based on their relative coordinates.
  4. Return the count of unique shapes.

Conclusion