# Java Interview with a FAANG engineer

### Interview Summary

**Problem type**  
Number of Unique Islands  
  
**Interview question**  
Given: A 2D array of integers representing land and water.  
Values of 0 represent water. Values of 1 are land.  
An "island" is a set of adjacent (N, S, E, or W) values = 1.  
Your task: count the number of unique island shapes.

For example:  
```
[[1, 1, 0, 0, 0, 0, 0],  
 [1, 0, 0, 0, 1, 1, 0],  
 [1, 0, 0, 0, 0, 1, 0],  
 [0, 0, 1, 1, 0, 0, 0],  
 [0, 0, 1, 0, 0, 1, 1],  
 [0, 0, 1, 0, 0, 1, 0]]  
```
There are four islands.  
The islands in the top left, and bottom 3rd column are the same shape.

### Interview Feedback

**Feedback about Hyper Bandit (the interviewee)**  
**Advance this person to the next round?**  
Yes

**How were their technical skills?**  
3/4  
**How was their problem solving ability?**  
3/4  
**What about their communication ability?**  
2/4

> Great interview. Good intuition and approach. Some prompting required to head in the right direction.  
>  
> **What went well:**  
>  
> - good questions to scope the question (minimum size, rows the same width) for your solution  
> - great initial approach for the easier part of the question  
> - good intuition for solving the second part of the question and good initial solution with a little prompting  
> - good problem-solving when confronted with edge case scenario  
>  
> **Room for improvement:**  
>  
> - variable and method naming. Single-letter variable names should be reserved for simple loops where you don't need the value out of that context, or for meanings that are obvious (l = length, w = width was fine, r for row and c for column would have been better than i, j) and "helper" methods should say what they are doing.  
> - some moments of silence as you thought, hard for me to know what you were thinking  
> - parameter mutability. Understand when you can/can't modify it.

**Feedback about Metal Taco (the interviewer)**  
**Would you want to work with this person?**  
Yes  
**How excited would you be to work with them?**  
4/4  
**How good were the questions?**  
4/4  
**How helpful was your interviewer in guiding you to the solution(s)?**  
4/4

### Interview Transcript

**Metal Taco:** Hello. How are you doing?  
**Hyper Bandit:** Good, how are you doing?  
**Metal Taco:** Fantastic, thank you. A pleasure to virtually meet you. Looks like we have a standard algorithmic interview for today.  
**Hyper Bandit:** Okay.  
**Metal Taco:** Alright, your lucky question today's...

**Hyper Bandit:** I'm thinking of doing it by going through the 2D array and once I meet a one, I will use a helper function...

**Metal Taco:** That sounds like a good approach to start with.

### Key Concepts

- An island is defined by contiguous 1s in the matrix.  
- The task involves identifying unique shapes by their relative positioning.
- It's important to communicate during problem solving to help the interviewer follow your thought process.  
- Efficient data structures like hash sets may be useful for tracking unique shapes.
