Given three integers N, X and Y, the task is to find the minimum integer that should be added to X to make it at least Y percent of N.
Input: N = 10, X = 2, Y = 40
Adding 2 to X gives 4 which is 40% of 10
Input: N = 10, X = 2, Y = 20
X is already 20% of 10
Approach: Find val = (N * Y) / 100 which is the Y percent of N. Now in order for X to be equal to val, val – X must be added to X only if X < val.
Below is the implementation of the above approach:
Time Complexity: O(1)
- Minimum elements to be added so that two matrices can be multiplied
- Minimum number of Parentheses to be added to make it valid
- Minimum edges to be added in a directed graph so that any node can be reachable from a given node
- Minimum elements to be added in a range so that count of elements is divisible by K
- Maximum difference elements that can added to a set
- Print elements that can be added to form a given sum
- Find the integers that doesnot ends with T1 or T2 when squared and added X
- Find amount to be added to achieve target ratio in a given mixture
- Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Minimum LCM and GCD possible among all possible sub-arrays
- Find the value of N when F(N) = f(a)+f(b) where a+b is the minimum possible and a*b = N
- Find minimum x such that (x % k) * (x / k) == n | Set-2
- Find minimum x such that (x % k) * (x / k) == n
- Minimum value possible of a given function from the given set
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.