Intermediate Level

Implement the kClosestPointsCount method that counts points included among the k closest points to the origin.

The input points contains size two-dimensional points, where each point is represented as [x, y]. The value k tells how many closest points should be selected.

Your task is to return the count of points that would be selected among the k closest points to the origin (0,0).

This method returns only the number of selected points, not the actual points. For example, if k = 1, the answer is 1 as long as at least one point exists.

Example 1
Input:
points (int[][]) = [[1,3],[-2,2]]
size (int) = 2
k (int) = 1
Return:
(int) 1
Example 2
Input:
points (int[][]) = [[3,3],[5,-1],[-2,4]]
size (int) = 3
k (int) = 2
Return:
(int) 2
Example 3
Input:
points (int[][]) = [[0,0]]
size (int) = 1
k (int) = 1
Return:
(int) 1

Calculate each point distance from the origin using squared distance.

Squared distance is enough because comparing x² + y² gives the same order as comparing actual distance, and it avoids square root calculation.

Sort the distances and count how many points can be selected, up to k. Since only the count is returned, the answer is min(k, size).

Pseudocode:

function kClosestPointsCount(points, size, k):
    create empty list distances
    for each point in points:
        x = point[0]
        y = point[1]
        distance = x * x + y * y
        add distance to distances
    sort distances in ascending order
    count = 0
    for i from 0 to min(k, size) - 1:
        count++
    return count
Run your code to see the result.