Find the Minimum and Maximum Number of Nodes Between Critical Points
A medium-tier problem at 69% community acceptance, tagged with Linked List. Reported in interviews at Info Edge and 1 others.
You're given a linked list with special "critical points" marked by local minima and maxima. Find the distance between the first and last critical point, returning both the minimum gap between any two consecutive critical points and the distance from start to end. This problem shows up in assessments at Info Edge and josh technology. The 69% acceptance rate reflects that it's easier than it looks once you nail the traversal pattern, but candidates who skip the edge cases (what if there's only one critical point, or none at all) tank the submission.
Companies that ask "Find the Minimum and Maximum Number of Nodes Between Critical Points"
Find the Minimum and Maximum Number of Nodes Between Critical Points is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe trick is recognizing that you need two passes, or one careful pass with state tracking. You're looking for nodes where a node's value is strictly less than both neighbors (minimum) or strictly greater than both neighbors (maximum). The gap between consecutive critical points is straightforward, but the minimum and maximum distance across the whole list requires you to store the position of the first critical point you see. A common pitfall: treating the head and tail nodes as candidates for critical points when they only have one neighbor. StealthCoder handles this instantly if you hit the problem live and blank on whether a single-neighbor node counts. Once you've identified all critical points, compute distances between them in a single second pass.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find the Minimum and Maximum Number of Nodes Between Critical Points recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find the Minimum and Maximum Number of Nodes Between Critical Points interview FAQ
Is this problem actually easy?+
It's medium for a reason. Finding critical points is straightforward, but handling edge cases (fewer than two critical points, gaps between consecutive ones) trips people up. At 69% acceptance, most candidates who understand linked list traversal and comparison logic pass it.
Do I need to store all critical points?+
No. Track the position of the current critical point and the previous one. That's enough to compute minimum gap. Also store the first critical point position to compute the distance from start to end.
What if there are no critical points or only one?+
Return -1, -1. The problem specifies this. Check it explicitly before you try to compute distances, otherwise you'll get index errors or return garbage.
Why is this asked at Info Edge and josh technology?+
It's a teaching problem for linked list mechanics. You need traversal, node value comparison, and basic position tracking. It's not hard, but it forces you to handle linked list navigation cleanly.
Can I use a separate array to store critical points?+
Yes, it's cleaner for some people. Iterate once, store all (position, node) pairs of critical points. Then iterate the array again to compute min gap and max distance. Trade space for clarity if you're not comfortable with single-pass logic.
Want the actual problem statement? View "Find the Minimum and Maximum Number of Nodes Between Critical Points" on LeetCode →