Find the K Closest Points

Problem:

Find the K closest points to the origin(0,0) in a 2D plane, given an array containing N points represented as tuples?

Distance is measured by using the Pythagorean theorem.

Examples:

Given points : [(-2,4) , (3,1), (0,-2), (-1,0), (-3, -2), (2, 1)] and k=2
Output = [(-1,0) , (0,-2)]

Note:
Order doesn’t matter, just need k closests points.
If points are tied for distance, arbitrarily break ties.

Hints and Answer Checklist