Given two ladders of height h1 and h2. The task is to find the maximum height that can’t be reached using any possible combination by the two ladders. If it is possible to reach all the heights then print 0.
Input: H1 = 2, H2 = 11
We cannot reach heights 1, 3, 5, 7 and 9.
So, the maximum possible height is 9.
Input: H1 = 7, H2 = 5
Approach: For the given numbers a and b, the maximum number c such that ax + by = c is not possible where x ≥ 0 and y ≥ 0 is Frobenius number which is equal to (a * b) – a – b.
Below is the implementation of the above approach:
Time Complexity: O(1)
- Maximum height of triangular arrangement of array values
- Find the height of a right-angled triangle whose area is X times its base
- Find maximum value of x such that n! % (k^x) = 0
- Find maximum among x^(y^2) or y^(x^2) where x and y are given
- Find the maximum possible value of a[i] % a[j] over all pairs of i and j
- Find three integers less than or equal to N such that their LCM is maximum
- Find maximum operations to reduce N to 1
- Find maximum xor of k elements in an array
- Find permutation with maximum remainder Sum
- Find a pair from the given array with maximum nCr value
- Given count of digits 1, 2, 3, 4, find the maximum sum possible
- Find pair with maximum GCD in an array
- Find the maximum number of handshakes
- Find a positive number M such that gcd(N^M, N&M) is maximum
- Find the node whose sum with X has maximum set bits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.