
If the given POINTS array is [(0,0),(1,1),(3,3)] and ‘K’ = 2, then the number of groups will be 2.
One group will be [(0,0) , (1,1)] and other will be [(3,3)].
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case contains two integers, 'N’ denoting the number of points in the ‘POINTS’ array and ‘K’.
The next ‘N’ lines of each test case has two integers corresponding to the x and y coordinate of POINTS[i].
For each test case, print a single integer corresponding to the number of groups.
Output for each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 3000
1 <= K <= 50.
-1000 <= X coordinate of 'POINTS'[i] <= 1000
-1000 <= Y coordinate of ’POINTS’[i] <=1000
Time limit: 1 sec
In this approach, we iterate over each pair of points, and if the euclidean distance between them is less than or equal to ‘K’, we will group them together. To group the points effectively, we will use a disjoint set union.
In this approach, we will first sort the ‘POINTS’ array based on x-coordinates, and recursively we will divide the points into two halves and group the points in the left half and right half. To group the points effectively, we will use a disjoint set union.
Algorithm:
Good Bad Graph
Good Bad Graph
COUNT ISLANDS
K-Repeating Substring
Sorted Doubly Linked List to Balanced BST
Longest Substring with K-Repeating Characters