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
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
Arrays
Single pass
Boolean flags
Edge cases
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported