Predict the class of a query point by a majority vote among its k nearest training rows (squared Euclidean distance). Distance ties are resolved in favour of the earlier training row, and a tied vote goes to the class that sorts first.
Implement solve(X, labels, q, k).
Returns. Return the winning class label, taken from labels.
Example 1
Input:
solve([[0.0], [1.0], [10.0], [11.0]], [0, 0, 1, 1], [0.5], 3)
Output:
0
Example 2
Input:
solve([[0.0], [2.0]], ['a', 'b'], [1.0], 2)
Output:
'a'
No results yet
Run your code to check it against the examples, or submit to run every test.