Consider two people moving in opposite direction with speeds U meters/second and V meters/second respectively. The task is to find how long will take to make the distance between them X meters.
Input: U = 3, V = 3, X = 3
After 0.5 seconds, policeman A will be at distance 1.5 meters
and policeman B will be at distance 1.5 meters in the opposite direction
The distance between the two policemen is 1.5 + 1.5 = 3
Input: U = 5, V = 2, X = 4
Approach: It can be solved using distance = speed * time. Here, distance would be equal to the given range i.e. distance = X and speed would be the sum of the two speeds because they are moving in the opposite direction i.e. speed = U + V.
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 ways to arrange K different objects taking N objects at a time
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Calculate speed, distance and time
- Distance between end points of Hour and minute hand at given time
- Distance traveled by Hour and Minute hand in given Time interval
- Distance of chord from center when distance between center and another equal length chord is given
- Find the distance covered to collect items at equal distances
- Minimum decrement operations to make Array elements equal by only decreasing K each time
- Convert characters of a string to opposite case
- Position of a person diametrically opposite on a circle
- 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)
- Program to find simple moving average
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Maximum possible intersection by moving centers of line segments
- Check if it is possible to return to the starting position after moving in the given directions
- Count possible moves in the given direction in a grid
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Time difference between expected time and given time
- Check if it is possible to draw a straight line with the given direction cosines
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.