# Longest Consecutive Sequence & Tree Cliff Grid

#### Watch someone solve the longest consecutive sequence & tree cliff grid problem in an interview with a FAANG engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Longest Consecutive Sequence / Tree Cliff Grid: C++ Interview with a FAANG Engineer - YouTube

### Interview Summary

#### Problem type
Longest Consecutive Sequence & Tree Cliff Grid

#### Interview question
The first problem asks the candidate to find the length of the longest consecutive integer sequence in an unsorted array, solved optimally in O(n) time using a hash set. The second is a custom grid problem: given a 2D cliff modeled as a binary grid where trees are stable only if connected to the bottom row, determine the resulting grid after cutting a specified tree and letting all newly unstable trees fall.

### Interview Feedback

#### Feedback about Hurricane Automaton (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?  
**3/4**

## 1. Strengths
- **Clarifying questions** — You asked good questions upfront instead of making assumptions and diving in blind. This is a green flag for interviewers  
- **Technical ability** — You are solid as an engineer. You solved Q1 independently and Q2 with only minor nudges  
- **Collaborative style** — You consistently checked in with the interviewer before moving forward, which shows good communication instincts

## 2. Room for Improvement

### Pacing
- You overcommunicated on Q1. By the time you were explaining, you already had the right answer  
- The rule of thumb: one good example to confirm understanding, then start coding  
- You could have finished Q1 roughly **8 minutes earlier**

### Time Allocation
- Real interviews are structured as easy Q1 + harder Q2  
- Your goal is to **bank time** on Q1 so you have a full runway for Q2  
- You were still explaining Q1 when you should have already been halfway through Q2

### Syntax Under Pressure
- The infinite loop bug was a simple `i++` vs `j++` mistake — classic one-off error  
- When you're in a time crunch and hit an infinite loop, **don't panic and rush**  
- Slow down, check your counters, check your loop increments — it's almost always something small like that

### Subarray vs. Consecutive Sequence
- There was a moment of confusion around whether the problem was asking for a subarray or a consecutive sequence  
- Know this distinction cold going into any interview:  
  - **Subarray** = elements must be literally adjacent, you cannot sort  
  - **Consecutive sequence** = elements just need to form a sequence numerically, order in the array doesn't matter, sorting or hash set both work

## 3. Open Notes
- The confusion about subarray vs. sequence came up early — you actually explained the correct answer to the interviewer before you realized you already had it. Trust yourself more in those moments  
- When you hit something that feels too straightforward, don't second-guess it. Ask one confirming question ("so I can just sort this?") and move on rather than sitting in uncertainty

## 4. What To Do Differently Next Interview
- **Get approval, then go** — Once the interviewer confirms your approach, stop re-explaining and start typing  
- **One trace, not a full walkthrough** — Walk through one example line by line to show you understand it, then run the test case and move forward  
- **Protect your Q2 time** — Treat Q1 like a sprint. Clean, correct, efficient, done  
- **When you hit a bug** — Pause, breathe, check your counters and loop variables first. Don't let a one-line fix spiral into a 5-minute panic  
- **Trust your instincts** — You clearly have the technical ability. The limiting factor right now is pacing and confidence, not knowledge

### Interview Transcript
Stealthy Elephant: So my name is Stealthy Elephant... 
Hurricane Automaton: Yeah. Yeah.
Stealthy Elephant: Perfect. So you have a few and you're going for senior engineer roles?
Hurricane Automaton: Yes. Yes.
Stealthy Elephant: Perfect. Perfect.

Hurricane Automaton: Okay.  
Stealthy Elephant: Yes. And do you have any final rounds coming up or are they all like beginner rounds, middle rounds?
Hurricane Automaton: Oh, no, no. These are, these are final rounds, like, which are coming up. So, uh, yeah, in a week's time, like, I'll be having final rounds with [REDACTED]

Stealthy Elephant: Okay, perfect.  
Hurricane Automaton: So given an unsorted array of integer nums, return the length of the longest consecutive elements sequence. So, okay, it's the longest, uh, sequence. So in the first one, the output is 4 because, uh, longest consecutive element sequence...

Stealthy Elephant: Yes, correct, correct...  
Hurricane Automaton: ...Can this have duplicates? I think yes, like here, this example had duplicates.

Stealthy Elephant: Perfect, perfect. All right, you're good. I think everything's good for this one. Let's move on to the next question.
Hurricane Automaton: Sure.
Stealthy Elephant: All right, let's do it.

### Feedback about Stealthy Elephant (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**

The feedback structure and the refreshing dialogue helped highlight the strengths and areas for improvement in both the candidate and interviewer, stressing the importance of clear communication and efficient problem-solving strategies.
