Maximum size of consecutives
Submissions: 167   Accuracy:

29.34%

  Difficulty: Easy   Marks: 2

Given a sorted array of distinct elements and an integer k. The array elements denote positions of points on 1-D number line, find the maximum size of subset of points that can have consecutive values of points which can be formed by placing another k points on the number line.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains two integers N and K and the second line contains N space separated array elements.

Output:
For each test case, print the maximum size of subset containing consecutive values in new line.

Constraints:
1<=T<=200
1<=N<=106
1<=K<=105
1<=A[i]<=106

Example:
Input:

2
8 4
1 2 3 4 10 11 14 15

3 3
11 12 15

Output:
8
6

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.