A car travels with an average speed of S km/h without any stoppage and with stoppage the speed of car reduces to an average of S1 km/h. The task is to find the time wasted per hour for the stoppage.
Input: S = 50, S1 = 30
Output: 24 min
Input: S = 30, S1 = 10
Output: 40 min
Approach: Take the first example,
Speed of car without any stoppage = 50 kmph i.e. 50 km in 60 min.
Speed of car with stoppage = 30 kmph i.e. 30 km in 60 min.
Now, if there will be no stoppage then 30 km can be covered in 36 min.
50 km –> 60 min
30 km –> (60 / 50) * 30 = 36 min
but it takes 60 min.
So, time for stoppage per hour is 60 min – 36 min = 24 min.
This can be calculated using the below formula:
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.