Given an array of integers and a number K. Write a program to find the maximum sum of a subarray of size K.

**Input:**

First line of input contains a single integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains two space separated integers N and K where N denotes the number of elements. Second line of each test case contains N space separated integers which denotes the elements of the array.

**Output:**

For each test case print the maximum sum of a subarray of size K.

**Constraints:**

1<=T<=100

1<=N<=10^{5}

1<=K<=N

**Example:**

**Input:**

2

4 2

100 200 300 400

9 4

1 4 2 10 23 3 1 0 20

**Output:**

700

39

Author: harsh.agarwal0

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

sabka_din_aayega | 342 |

maggiiiii | 262 |

Savage_19 | 226 |

thanuvinu94 | 211 |

lost_found | 173 |

Bishnu Dev Panda | 803 |

sabka_din_aayega | 653 |

Anugrah_kumar | 562 |

okayboss | 561 |

maggiiiii | 545 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.