Skip to main content
All Questions

Find the contiguous interval of at least K elements with the maximum sign-twisted sum.

Unlock detailed company stats for this questionUpgrade

Given an integer array A of performance changes over N intervals, find a non-empty contiguous interval [i..j] of size at least K maximizing the cumulative improvement, where the sum is computed as -1*A[i] + A[i+1] + ... + A[j]. Framed as analyzing an ML model's recommendation quality: positive values are improvements, negative values declines. The twist is that the first element of the selected interval is negated, and the interval must contain at least K elements.

Format · DSA round of an Applied Scientist loop.

Community answers

No answers contributed by the community yet.

Related courses

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.

Course

SQL Interview Prep Course

Prepare for SQL interviews with lessons on joins, aggregations, and window functions, then practice real SQL interview questions in an interactive editor with expert solutions.