Detect a Dip, Spike, Then Partial Recovery in Engagement Scores
Last updated: November 29, 2026
Quick Overview
Given a sequence of engagement scores, return True if there exist indices i < j < k with scores[i] < scores[k] < scores[j], meaning a low point, then a peak, then a value between them.
Meta
November 29, 20260
0
0 solved
Given a sequence of engagement scores, return True if there exist indices i < j < k with scores[i] < scores[k] < scores[j], meaning a low point, then a peak, then a value between them.
A Meta screen question in the style of anomaly hunting on engagement time series: a metric dips, spikes, and then settles somewhere in between. The interviewer is checking whether you get from O(n^3) to O(n) by scanning right to left with a decreasing stack that tracks the best 'middle' value.
What the Interviewer Expects
- Start with a brute force and a prefix-min O(n^2) improvement
- Scan from the right keeping candidates for the peak on a stack
- Track the largest value popped as the best third element
- Return as soon as a value smaller than that third element appears
- Explain why popped values are the right candidates
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Return the actual triple of indices.
- Count how many such triples exist.
- Detect the pattern with i < j < k < l and four ordering constraints.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list s of integers, length up to 2 * 10^5. Output: whether some i < j < k has s[i] < s[k] < s[j]. Values may repeat; all inequalities are strict....
High-Level Design
Walk from right to left. Treat the current element as a candidate for the peak s[j]. Keep a stack of values seen to the right, decreasing from bottom to top, and a variable third holding the large...