@@ -103,8 +103,8 @@ function maxSubarrayOfSizeK(arr, k) {
103103 return maxSum
104104}
105105
106- max_sub_array_of_size_k (3 , [2 , 1 , 5 , 1 , 3 , 2 ])// 9
107- max_sub_array_of_size_k (2 , [2 , 3 , 4 , 1 , 5 ])// 7
106+ maxSubarrayOfSizeK (3 , [2 , 1 , 5 , 1 , 3 , 2 ])// 9
107+ maxSubarrayOfSizeK (2 , [2 , 3 , 4 , 1 , 5 ])// 7
108108````
109109- Time complexity will be ` O(N*K) ` , where ` N ` is the total number of elements in the given array
110110
@@ -313,10 +313,17 @@ function totalFruit (fruits) {
313313 return windowMax
314314};
315315
316- totalFruit ([3 ,3 ,3 ,1 ,2 ,1 ,1 ,2 ,3 ,3 ,4 ])// 5
317- totalFruit ([1 ,2 ,1 ])// 3,We can pick from all 3 trees.
318- totalFruit ([0 ,1 ,2 ,2 ])// 3,We can pick from trees [1,2,2].If we had started at the first tree, we would only pick from trees [0,1].
319- totalFruit ([1 ,2 ,3 ,2 ,2 ])// 4,We can pick from trees [2,3,2,2]. If we had started at the first tree, we would only pick from trees [1,2].
316+ totalFruit ([3 ,3 ,3 ,1 ,2 ,1 ,1 ,2 ,3 ,3 ,4 ])
317+ // 5
318+
319+ totalFruit ([1 ,2 ,1 ])
320+ // 3,We can pick from all 3 trees.
321+
322+ totalFruit ([0 ,1 ,2 ,2 ])
323+ // 3,We can pick from trees [1,2,2].If we had started at the first tree, we would only pick from trees [0,1].
324+
325+ totalFruit ([1 ,2 ,3 ,2 ,2 ])
326+ // 4,We can pick from trees [2,3,2,2]. If we had started at the first tree, we would only pick from trees [1,2].
320327````
321328### Map Object Solution
322329```` js
0 commit comments