You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (arr.length < n) return null; //return null if array is empty.
for(let i=0; i<n; i++){
max +=arr[i] //return sum of first n numbers.
}
temp = max;
for (let j = n; j < arr.length; j++) { //run after n numbers upto length of array.
temp = temp - arr[j-n] + arr[j]; //remove the element from beginning and add the element after n numbers and slide through the numbers. (sliding window pattern)