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
- Clarified the question before jumping to the solution
- Candidate was able to come up with the algorithm with minimal hints
- Provided the right space and time complexity
- Coded the solution with only one or two bugs
- Good modularity in code
- Was able to come up with a workable if inefficient solution to rotation extension
Areas of Improvements
- Use better naming convention than i,j
- Check major parts of logic before signing off on a function
Advice for future interviews
- Practice random questions on leetcode in timebound manner to get used to new kind of questions
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
- Identify connected components of 1s.
- Use Depth First Search (DFS) or Breadth First Search (BFS) to explore each shape.
- Store and deduplicate found shapes based on their relative coordinates.
- Return the count of unique shapes.
Conclusion
- The candidate demonstrated a structured approach to problem-solving.
- Clear communication and a stepwise understanding of the algorithm were indicated as strengths while minor bugs in code and ineffective naming conventions were identified as areas for improvement.