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)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Number of hours after which the second person moves ahead of the first person if they travel at a given speed
- Lucky alive person in a circle | Code Solution to sword puzzle
- Determine the position of the third person on regular N sided polygon
- Convert characters of a string to opposite case
- Time until distance gets equal to X between two objects moving in opposite direction
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Find two vertices of an isosceles triangle in which there is rectangle with opposite corners (0, 0) and (X, Y)
- Number of ways to arrange 2*N persons on the two sides of a table with X and Y persons on opposite sides
- Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Find the vertex diagonally opposite to the vertex M from an N-sided polygon
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Equation of circle when three points on the circle are given
- Check if a circle lies inside another circle or not
- Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Area of the circle that has a square and a circle inscribed in it
- Distributing M items in a circle of size N starting from K-th position
- Number of handshakes such that a person shakes hands only once
- Number of different positions where a person can stand
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.