Best Engagement Window by Minimum Times Sum Score

Last updated: November 29, 2026

Quick Overview

For a creator's daily engagement counts, the score of a contiguous window is (minimum day in the window) times (sum of the window). Return the maximum score over all non-empty windows.

LinkedIn
Coding & Algorithms
Software Engineer
LinkedIn
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


For a creator's daily engagement counts, the score of a contiguous window is (minimum day in the window) times (sum of the window). Return the maximum score over all non-empty windows.

Creator analytics at LinkedIn reward sustained engagement, and this metric penalizes a single viral spike. The onsite interviewer looks for the monotonic stack insight that each day can be the window minimum over a maximal range, combined with prefix sums.

What the Interviewer Expects
  • Notes the O(n^2) or O(n^3) brute force
  • Fixes each element as the minimum and finds its maximal window
  • Uses a monotonic increasing stack to find previous and next smaller elements
  • Uses prefix sums for O(1) window sums
  • Handles equal values without double counting or missing windows
Key Topics to Cover
monotonic stack
prefix sums
next smaller element
array optimization
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 window boundaries as well?
  • What if the score is min times length, like largest rectangle in a histogram?
  • How would you compute this for every creator in a daily batch job?
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: list of nonnegative ints, length up to 10^5. Output: the maximum of min(w) * sum(w) over contiguous windows w. No modulo is needed in Python. Empty list returns 0....

High-Level Design

In the optimal window, some element is the minimum. If day i is the minimum, extending the window as far as possible while every element is at least a[i] only increases the sum (values are nonnegati...


Submit Your Answer
Markdown supported