Last Updated: 27 Feb, 2025

Convert Speed

Easy

Problem statement

You are given 'X', representing the speed of an object in kmph.

Convert the speed to m/sec. Your result should be accurate up to 3 decimal places.

Input Format :
The first line of input contains a single integer 'X', which denotes the speed of the object in kmph.
Output Format :
Return the speed of the object in m/sec. 
Note :
You don’t need to print anything. Just implement the given function.
Constraints :
10 <= 'X' <= 10^9

Time Limit: 1 sec

Approaches

01 Approach

Approach:

  • Let us determine the formula for the conversion
    • We know that: 1 km = 1000 metre & 1 hour = 60 minutes = 3600 seconds
    • Therefore, 1 kmph = 1000 metre / 3600 seconds = ( 5 / 18 ) m/sec
    • Thus, we need to multiply the input with ( 5 / 18 ) to get our answer.
  • We need to avoid integer overflow and floating point precision errors while using the above formula.


 

Algorithm:

  • Return ‘( 5 * X ) / 18’