Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6381 |

@blackshadows | 6329 |

@mb1973 | 5388 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@1905439 | 553 |

@terabaap123 | 508 |

@smitadiwedi1991 | 279 |

@DevanandJayakumar | 250 |

@atishagusain | 244 |

@gupta_10 | 226 |

@shubhamkhullar7 | 224 |

@nipun edara | 224 |

@balunagar | 204 |

@sharmachandan487 | 204 |

@arshjit_singh7 | 190 |

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?

Yes
K Subarray Sum

...