Detect Whether a Daily Active User Series Is Monotonic
Last updated: November 29, 2026
Quick Overview
Given a list of daily active user counts, return true if the series is entirely non-decreasing or entirely non-increasing, and false otherwise.
Meta
November 29, 20260
0
0 solved
Given a list of daily active user counts, return true if the series is entirely non-decreasing or entirely non-increasing, and false otherwise.
Meta screens often open with a quick array question framed around a metrics dashboard. The interviewer checks that you handle flat stretches (equal neighbors) correctly and finish in a single pass rather than two.
What the Interviewer Expects
- Clarifies that equal adjacent values are allowed in either direction
- Solves it in one pass with two flags or a direction variable
- Returns early once both directions are ruled out
- Handles empty and single-element lists
- Writes concise, readable code
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
- How would you return the longest monotonic contiguous stretch instead?
- What if the data arrives as a stream and you must answer after each value?
- How would you allow a tolerance of k percent noise between days?
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: a list of integers (possibly empty). Output: a boolean. Non-decreasing means a[i] <= a[i+1] for all i, non-increasing means a[i] >= a[i+1]. A constant series satisfies both. Target O(n) tim...
High-Level Design
Track two booleans, can_rise and can_fall, both starting true. Every strict increase between neighbors rules out non-increasing, and every strict decrease rules out non-decreasing. Equal neighbors...