find subarray at a given length with the maximum average
Anonymous
1. create a queue with a size of k ( subarray length), the queue cant contains more than k elements, in new on is entered the last is out. 2. The queue should be with the current sum 3. loop the array and add the first k elements to the queue 4. now each new element : - add new element to the queue (the queue should remove the last one) - check if sum is bigger, if yes save the queue elements as maxsubarray return maxsubarray
Check out your Company Bowl for anonymous work chats.