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 of an ML model's recommendations over N intervals (positive values are improvements, negative values declines), find a non-empty contiguous interval [i..j] of size at least K that maximizes the cumulative improvement, where the sum is computed as -1*A[i] + A[i+1] + ... + A[j]. The first element of the selected interval is negated.

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.