All challenges
Code AnalysisIntermediate 50s

Trace: Sliding Window Max Sum

What number is printed?
Starter code
const a=[1,3,-1,-3,5,3,6,7],k=3;
let s=0;for(let i=0;i<k;i++)s+=a[i];
let m=s;
for(let i=k;i<a.length;i++){s+=a[i]-a[i-k];if(s>m)m=s;}
console.log(m)

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle