#### Loading...

Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5765
@blackshadows 5715
@akhayrutdinov 5111
@mb1973 4993
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Complete Leaderboard
Find Nth root of M
Easy Accuracy: 14.73% Submissions: 95 Points: 2

You are given 2 numbers (n , m); the task is to find n√m (nth root of m).

Example 1:

Input: n = 2, m = 9
Output: 3
Explanation: 32 = 9


Example 2:

Input: n = 3, m = 9
Output: -1
Explanation: 3rd root of 9 is not
integer.


Your Task:
You don't need to read or print anyhting. Your task is to complete the function NthRoot() which takes n and m as input parameter and returns the nth root of m. If the root is not integer then returns -1.

Expected Time Complexity: O(n* log(m))
Expected Space Complexity: O(1)

Constraints:
1 <= n <= 30

1 <= m <= 109

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?

#### My Submissions:

Login to access your submissions.

Find Nth root of M