Interview with a Meta engineer.

An Interview with a Meta engineer

Watch someone solve the peaks and valleys problem in an interview with a Meta engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Interview Summary

Problem type
Peaks and Valleys
Interview question
Determine Peak or Valley from an integer array satisfying the following properties.

  1. At any given point in the array, the difference between two elements is +/- 1. Ex. Arr[i] = A[i - 1] is +/- 1.
  2. There should be at most one peak or valley.

Return the index of the peak or valley from the given integer array.

Examples:
Valley - [3, 2, 1, 0, 1] ==> 3
Peak - [4, 5, 6, 7, 8, 9, 8, 7] ==> 5
[4, 5, 6, 7, 8, 9] -> -1

Interview Feedback

Feedback about Orthogonal Warrior (the interviewee)
Advance this person to the next round?
Yes

TC will be evaluated based on

  1. Communication: Edge cases, clarifying questions, communicating your solution
  2. Problem Solving: How TC is approaching the question, brute force and optimal, data structures considered
  3. Coding: Clean and readable code
  4. Verification: Time and space complexities, example run through

Went well:

  1. Communication: Asked clarifying questions suggesting counter examples. Was able to understand TC's communication throughout
  2. Problem Solving: Great job here. Was able to come up with an optimal solution very quickly. Proposed both brute force and optimal on question one. Took a systematic approach to both questions to arrive at the solution
  3. Coding: Very good coding skills. Clean and easy to understand code.
  4. Verification: Gave the right time and space complexities. Did example run throughs to verify the code

Minor Suggestions:

  1. Problem Solving: Perhaps writing down the pseudocode might come in handy for a more complex question in the hard range or an unfamiliar pattern, to help TC and the interviewer see the gaps if any
  2. Verification: Example run through with use of variables like you did in the first question.

Feedback about Absurd Penguin (the interviewer)
Would you want to work with this person?
Yes

Fabulous interview, boosted my confidence and feeling great going into the onsite rounds. Thank you so much!

Interview Transcript

Absurd Penguin: So I see you're interviewing for Facebook.
Orthogonal Warrior: I am indeed.
Absurd Penguin: And you're which? Are you going to be attending a screening or is it going to be a full loop? That's coming.
Orthogonal Warrior: This is going to be for the full round. I've already been through the screening.

Absurd Penguin: Awesome. So you already know the format of the interview. So it's going to be about 20 minutes on each coding question. And the last five minutes, they would allow for you to ask any questions that you have for them.
Orthogonal Warrior: Yep.
Absurd Penguin: So let's try to keep it similar. We can do 20ish minutes on each question. I mean, it's okay if you go over, but I'll point that out towards the end.
Orthogonal Warrior: Sounds good. Awesome. Then let's jump right in. So here's your question. Let me go ahead and explain to you the question. So your input is going to be an array. If you look at this first example, you see that it's steadily decreasing until it reaches zero.
Orthogonal Warrior: Right.
Absurd Penguin: And past this, it starts increasing. Likewise, in the second example, you see that steadily increasing until it reaches nine, and then it starts steadily decreasing. So here, in the first example, this is the valley in the array. In the second example is the peak in the array.
Orthogonal Warrior: Okay.
Absurd Penguin: So you're expected to return the index of the peak or valley, not the value itself, but the index of the peak or valley.
Orthogonal Warrior: Ah, the index of the peak or the valley. Gotcha.
Absurd Penguin: Well, please go ahead.
Orthogonal Warrior: Okay. And it's the index of the peak or the valley. So I, in this case, I could return 3 or 0, because 13 is technically the peak of this array.
Absurd Penguin: No, no. So that's not. So let me go ahead and explain the couple conditions that I have here. You'll get more clarity on what the expected output is.

... (the conversation continues with coding and clarification steps leading to the solution)

Orthogonal Warrior: Yeah, the time complexity is O(log N) and what is the space complexity?
Absurd Penguin: Yeah, the time complexity is O(log N). The space complexity is constant. We only instantiate two pointer variables.

Absurd Penguin: Awesome. All right, I'm happy with the solution. Can move on to the next question.
Orthogonal Warrior: Perfect.

Absurd Penguin: Ready? Yeah. So, next question. Kind of straightforward in terms of question. So you're expected to convert a binary search tree to a sorted doubly linked list.

We know exactly what to do and say to get the company, title, and salary you want.

Interview prep and job hunting are chaos and pain. We can help. Really.