Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6454 |

@blackshadows | 6380 |

@mb1973 | 5710 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3709 |

@mantu_singh | 3556 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1285 |

@gurshehzadsingh | 1052 |

@pritsahkar2000 | 812 |

@nithinreddy3210 | 801 |

@satyamchhatrala | 796 |

@iib2019024 | 745 |

@mohanreddy8847 | 704 |

@iamchaitanyahegde | 662 |

@workit | 646 |

@shafeeq3543 | 645 |

@AkashLahoty | 642 |

Complete Leaderboard |

Given an integer array **arr **of size **N** and two integers **K **and **M**, the task is to find **M **largest sums of **K** sized subarrays.

**Input: **

1. The first line of the input contains a single integer* * **T** denoting the number of test cases. The description of **T** test cases follows.

2. The first line of each test case contains three integers** N****, K, **and** M.**

3. The next line contains **N** space-separated integers.

**Output:** For each test case, print **M** space-separated integers (Print the sums from the maximum to minimum)

**Constraints:**

1. 1 <= T <= 100

2. 1 <= K <= N <= 10^{4}

3. 1 <= M <= N - K + 1

4. 1 <= arr[i] <= 10^{5}

**Example:
Input:**

2

5 2 3

10 11 10 11 12

5 5 1

1 2 3 4 5

**Output:**

23 21 21

15

**Explanation:
Test Case 1: **2 sized subarray sum are {21, 21, 21, 21, 23}, We need to print 3 largest sums from maximum to minimum

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

K Subarray Sum

...