Python Interview with a Meta engineer.

Python Interview with a Meta engineer

Interview Summary

Problem type

Find the Minimum and Maximum Number of Nodes Between Critical Points

Interview question

  1. A critical point in a linked list is defined as either a local maxima or a local minima. A node is a local maxima if the current node has a value strictly greater than the previous node and the next node.

A node is a local minima if the current node has a value strictly smaller than the previous node and the next node.

Given a linked list head, return an array of length 2 containing [minDistance, maxDistance] where minDistance is the minimum distance between any two distinct critical points and maxDistance is the maximum distance between any two distinct critical points. If there are fewer than two critical points, return [-1, -1].

  1. Given an array of integers arr, return true if and only if it is a valid mountain array.

Interview Feedback

Feedback about Immutable Laser (the interviewee)

Overall: Candidate makes sure they understand the problem by asking clarification questions around the problem and working through the examples. Candidate can articulate their solutions well. Candidate analyses the complexity of their solution well. Candidate reasons about how optimizing their solution further is not possible. Candidate writes working code with good speed. Candidate has good testing/debugging skills. Overall, it would be a hiring call based on this interview performance.

Notes:

Feedback about Red Maelstrom (the interviewer)

Overall Feedback: I liked the question choices since I have not seen them before and they test fundamental skills rather than require "tricks" to solve. In addition, you gave a very appropriate amount of nudging when I was thinking in the right/wrong direction. I also appreciate the advice you gave me for system design.

Interview Transcript

Red Maelstrom: So let me just paste the first question. So, yeah, you have a link list as an input. A node is a critical point if it is a local minima or local maxima, and as name suggests, local minimum maxima nodes which have values greater, strictly greater, or strictly less than previous, and a next node. So given such a link list, you have to return two things. Minimum distance between any two critical points and the maximum distance between any two critical points. Go through the question and the examples and let me know if you have any doubts.

Immutable Laser: Okay, so a node is a local maximum if the current node has a value strictly greater than the previous node and the next node. Okay, that makes sense. So it's like the maximum, it's like the peak node.

... (continuing with the transcript and interview details).

Analysis of the Mountain Array

An array is a mountain array if and only if the array length is greater than or equal to three. The conditions for a valid mountain are:

  1. There exists an index I such that the array is strictly increasing until that index.
  2. After that index, the array is strictly decreasing.

Edge Cases to Consider: