Java Interview with a FAANG engineer.

Java Interview with a FAANG engineer

Watch someone solve the find the minimum and maximum number of nodes between critical points 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.

Java interview with a FAANG engineer: Minimum and Maximum Number of Nodes Between Critical Points - YouTube

Java interview with a FAANG engineer: Minimum and Maximum Number of Nodes Between Critical Points

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.

Note that a node can only be a local maxima/minima if there exists both a previous node and a 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. arr is a mountain array if and only if: * arr.length >= 3 * There exists some i with 0 < i < arr.length - 1 such that: * arr[0] < arr[1] < ... < arr[i - 1] < arr[i] * arr[i] > arr[i + 1] > ... > arr[arr.length - 1]

Interview Feedback

Feedback about Jocular Almond (the interviewee)

Advance this person to the next round? Yes

How were their technical skills? 4/4

How was their problem-solving ability? 4/4

What about their communication ability? 4/4

Overall: TC is really good in terms of clarifying the questions and articulating their solution. Their communication skills and speed of implementation is good. TC was able to get the optimal solution for both problems on the first go. TC proactively shared the time and space complexity of their solutions. It would be a strong hire call based on this interview performance.

Notes:

Feedback about Red Maelstrom (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

Very grateful for the feedback on the interview and the guidance at the end.

Interview Transcript

Red Maelstrom: So, yeah, so basically we'll spend like 45 minutes on coding problems and I'll keep like the last 10-15 minutes for feedback.

Jocular Almond: Sure.
Red Maelstrom: Here is the first question.

Jocular Almond: You it?
Red Maelstrom: Basically, you have a linked list as input, head of a linked list as input, and there are a few definitions. Like a critical point is any node in a linked list which is either a local minima or local maxima. Local minima is a node which is strictly lesser than its previous node, and a local maxima is a node which is strictly greater than its previous node.

Given such a linked list, you have to return two things: one is the minimum distance between any two critical points and the maximum distance between any two critical points. Go through the question and the example. If you have any doubt, let me know.

Jocular Almond: Sure. Okay, so the problem is that we want to return the minimum distance and also the maximum distance between any two critical points. If we just look at the example here, that would help.

[Continued in interview...]

This continues throughout the interview, discussing various aspects of the problem and providing additional solution attempts and clarifications until reaching the coding exercise to implement solutions.