Given a positive integer K, a circle center at (0, 0) and coordinates of some points. The task is to find minimum radius of the circle so that at-least k points lie inside the circle. Output the square of the minimum radius.
Input : (1, 1), (-1, -1), (1, -1), k = 3 Output : 2 We need a circle of radius at least 2 to include 3 points. Input : (1, 1), (0, 1), (1, -1), k = 2 Output : 1 We need a circle of radius at least 1 to include 2 points. The circle around (0, 0) of radius 1 would include (1, 1) and (0, 1).
The idea is to find square of Euclidean Distance of each point from origin (0, 0). Now, sort these distance in increasing order. Now the kth element of distance is the required minimum radius.
Below is the implementation of this approach:
This article is contributed by Anuj Chauhan. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Find the number of points that have atleast 1 point above, below, left or right of it
- Radii of the three tangent circles of equal radius which are inscribed within a circle of given radius
- Find a point that lies inside exactly K given squares
- Find if a point lies inside, outside or on the circumcircle of three points A, B, C
- Find intersection point of lines inside a section
- Check if a circle lies inside another circle or not
- Equation of circle from centre and radius
- Radius of the circle when the width and height of an arc is given
- Number of rectangles in a circle of radius R
- Area of Equilateral triangle inscribed in a Circle of radius R
- Angular Sweep (Maximum points that can be enclosed in a circle of given radius)
- Triangle with no point inside
- Check if a point is inside, outside or on the ellipse
- Check if a point is inside, outside or on the parabola