There are n people standing on the circumference of a circle. Given the position of a persom m, the task is to find the position of the person standing diametrically opposite to m on the circle.
Input: n = 6, m = 2
Position 5 is opposite to 2 when there are 6 positions in total
Input: n = 8, m = 5
Approach: There are two cases:
- If m > n / 2 then answer will always be m – (n / 2).
- If m ≤ n / 2 then answer will always be m + (n / 2).
Below is the implementation of the above approach:
Time Complexity: O(1)
- Determine the position of the third person on regular N sided polygon
- Lucky alive person in a circle | Code Solution to sword puzzle
- Distributing M items in a circle of size N starting from K-th position
- Number of hours after which the second person moves ahead of the first person if they travel at a given speed
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Check if a circle lies inside another circle or not
- Equation of circle when three points on the circle are given
- Convert characters of a string to opposite case
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given
- Find two vertices of an isosceles triangle in which there is rectangle with opposite corners (0, 0) and (X, Y)
- Time until distance gets equal to X between two objects moving in opposite direction
- Number of different positions where a person can stand
- Number of handshakes such that a person shakes hands only once
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.