Answer: SLICE PAY Online Assessment Hiring Question | Off-Campus (2024))

Answer · Posted Jun 2026

Approach Traverse the linked list while keeping track of: Previous node Current node Next node Check whether the current node is: Greater than both neighbors (local maxima) Smaller than both neighbors (local minima) Store the index of every critical point. If fewer than 2 critical points exist: Return [-1, -1] Otherwise: Find the minimum distance between consecutive critical points. Find the maximum distance between the first and last critical point. Strategy Use a single traversal of the linked list. Store ...

The full answer & interview discussion are available to premium members.

Log in Create a free account