![]() |
VOOZH | about |
Given two integers N and K, the task is to find the Nth root of the K.
Examples:
Input: N = 3, K = 8
Output: 2.00
Explanation:
Cube root of 8 is 2. i.e. 23 = 8Input: N = 2, K = 16
Output: 4.00
Explanation:
Square root of 16 is 4, i.e. 42 = 16
Approach: The idea is to use logarithmic function to find the Nth root of K.
Let D be our Nth root of the K,
Then,
Apply logK on both the sides -
=>
=>
=>
Below is the implementation of the above approach:
3.000000
Time Complexity: O(1)
Auxiliary Space: O(1)