Convert floating point to natural number
Basic Accuracy: 43.35% Submissions: 30 Points: 1

Given a positive floating point number N, the task is to find the smallest integer k, such that when we multiply k with N, we get a natural number.
 

Example 1:

Input: N = "30.25"
Output: 4
Explanation: 30.25 * 4 = 321, there is no 
number less than 4 which can convert 30.25
into natural number.

Example 2:

Input: N = "5.5"
Output: 2
Explanation: 5.5 * 2 = 11, there is no number
less than 2 which can convert 5.5 into 
natural number.

 

Your Task:
You don' need to read or print anything. Your task is to complete the function findMinMultiple() which takes N as input parameter in string format and returns the minimum k such that when we multiply it with N we get a natural number.

 

Expected Time Complexity:O(c) where c is constant
Expected Space Compelxity: O(1)

 

Constraints:
1 <= N <= 1000

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Convert floating point to natural number

Output Window