C++ Interview with a FAANG engineer.
C++ Interview with a FAANG engineer
Interview Summary
Problem type
Buildings with an ocean view
Interview question
There are n buildings in a line. You are given an integer array heights of size n that represents the heights of the buildings in the line.
The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Return a list of indices (0-indexed) of buildings that have an ocean view, sorted in increasing order.
Example 1:
Input: heights = [4,2,3,1]
Output: [0,2,3]
Explanation: Building 1 does not have an ocean view because building 2 is taller.
Example 2:
Input: heights = [4,4,1]
Output: [1, 2]
Interview Feedback
Feedback about Digital Fresh (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?
4/4
Strengths:
- Communication:
- Positive, affable; seems great to work with
- Attentive listener and open to hints while being proactive to find solutions (and persistent)
- Time management:
- Great job in general on asking clarifying questions, sharing thought process for solution space, and implementing code, especially on the first problem
- Technical:
- Very comfortable with arrays
- Time and space complexity spot on
- Overall looks solid on general c++
Potential areas of improvement
- Problem solving:
- For the second problem with skylines, had more components and nuances to it: recommend to walk through one or two complete examples
- In the examples, articulate more on what your solution should track (e.g., running sum vs. current max score)
- Technical:
- Using "&" in method signature
- Instead of reversing an array, you could use STL's "reverse"
- Proactively write down Time and Space complexity at the end of the solution
- Practice iterating through hash maps/dictionaries in C++
Interview Transcript
Digital Fresh: Yeah, I'm looking for like an E3 level. I have two years of experience, but yeah, I'm still looking for more of an entry level role.
Stochastic Panda: Excellent. So let's move on to the interview question. Here we go.
- For the first interview question, what would you say is the time and space complexity?
Digital Fresh: Time is O(N) and Space is also O(N).
Stochastic Panda: Okay, great. I think this is looking good. Let's move on to one more question and let's see if it's okay. I'll paste the question starting now. Here we go.
Second Problem: The Skyline of Buildings
Interview question
You are given an integer array heights of size n. Each element height[i] represents the height of the ith building. The skyline is valid if it meets the following conditions: The first and last building in the skyline have the same height. Return the maximum possible score of some valid skyline after demolishing buildings.
- Example 1: Input: [4,3,4] → Output: 4
- Example reasoning: The valid skyline is simply the two 4s on either end.
Expected Output
For both interviews, it is expected that a candidate should clarify the output they are seeking.
Feedback about Stochastic Panda (the interviewer)
- Would you want to work with this person?
Yes - Overall performance I would give…
4/4
Closing Remarks
If you feel you could have done something better on the second question ask your mentor how you might solidify your code.
Explore resources available on Leetcode for practice.