Google: sum of k small subarray size m

643
Oct 11, 2025

Find the sum of K smallest element in all subarrays of size M. arr = [3, 1, 4, 5, 7, 8,11]; M=4, k=3 sum= [8, 10,16,20] i said correct brute force but on optimizing i was stuck using single multiset but then i got the intution of using 2 multiset one to store the smallest k and other for rest of elements. Interview questions [1] Question 1 Find the sum of K smallest element in all subarrays of size M. arr = [3, 1, 4, 5, 7, 8,11]; M=4, k=3 sum= [8, ] //google dev

Comments (3)