![]() |
VOOZH | about |
Given two numbers L and R, the task is to find two distinct minimum positive integers X and Y such that whose LCM lies in the range [L, R]. If there doesn't exist any value of X and Y then print "-1".
Examples:
Input: L = 3, R = 8
Output: x = 3, y=6
Explanation:
LCM of 3 and 6 is 6 which is in range 3, 8Input: L = 88, R = 90
Output: -1
Explanation:
Minimum possible x and y are 88 and 176 respectively, but 176 is greater than 90.
Approach: The idea is to choose the value of X and Y in such a way that their LCM lies in the given range [L, R]. Below are the steps:
Below is the implementation of the above approach:
3, 6
Time Complexity: O(1)
Auxiliary Space: O(1)