You are given an array points, where points[i] = [x, y] is a point on a plane, and an integer radius. Two points are linked when the Euclidean distance between them is at most radius.
Points form clusters by chaining. A point joins a cluster when it is linked to any point already in it, and a cluster stops growing once no outside point is linked to any of its members. So two points far apart still share a cluster if a path of linked points connects them. A point with no links is a cluster on its own.
Return the number of clusters.
Input: points = [[0,0],[3,4],[10,0],[13,4]], radius = 5
Output: 2
[0,0] and [3,4] are exactly 5 apart, and "at most radius" includes it, so they link. [10,0] and [13,4] link the same way. The closest pair across the two, [3,4] and [10,0], is about 8.06 apart.
Input: points = [[0,0],[8,0],[4,0],[20,20]], radius = 4
Output: 2
[0,0] and [8,0] are 8 apart, but [4,0] is 4 from each, so all three chain into one cluster. Scanning in order and only comparing a point with the clusters seen so far gives 3: [8,0] would start its own cluster before [4,0] arrives to join them. [20,20] is alone.
Input: points = [[1,1],[1,1],[2,2]], radius = 0
Output: 2
The two copies of [1,1] are 0 apart, so they link even with radius = 0. [2,2] is a cluster on its own.
1 <= points.length <= 1000points[i].length == 2-10^4 <= x, y <= 10^40 <= radius <= 3 * 10^4