Given the head start that A gives to B and C in a 100-meters race. The task is to find the head-start that B can give to C in the same race.
Input: B = 10 meters, C = 28 meters Output: 20 meters B can give C a start of 20 meters. Input: B = 20 meters, C = 50 meters Output: 62 meters B can give C a start of 62 meters.
Total meters in a race = 100 meters.
A is ahead of B by 10 meters. When A completed it’s 100 meters B completed it’s 90 meters.
Similarly, A is ahead of C by 28 meters. When A completed it’s 100 meters C completed it’s 72 meters.
Now, When B completed it’s 90 meters C completed it’s 72 meters.
So when B completed it’s 100 meters C completed it’s 80 meters.
–> (( C * 100) / B)
–> (( 72 * 100) / 90) i.e 80 meters
So B can give C a start of 20 meters
Below is the implementation of the above approach:
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 sequences which has HEAD at alternate positions to the right of the first HEAD
- Find start and ending index of an element in an unsorted array
- Aptitude | Race | Question 4
- Aptitude | Race | Question 5
- Aptitude | Race | Question 2
- Length of race track based on the final distance between participants
- Count Number of animals in a zoo from given number of head and legs
- Sub-strings that start and end with one character and have at least one other
- Slow Start Backoff Algorithm for Ad-Hoc
- Count of subarrays which start and end with the same element
- Number of substrings that start with "geeks" and end with "for"
- Program to find value of 1^k + 2^k + 3^k + ... + n^k
- Program to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to find last two digits of 2^n
- Program to find sum of the given sequence
- Program to find the value of sin(nΘ)
- Program to find the value of tan(nΘ)
- Program to find Sum of the series 1*3 + 3*5 + ....
- Program to find HCF iteratively
- Program to find the sum of the series 1 + x + x^2+ x^3+ .. + x^n
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.
Improved By : chitranayal