Count K-th Roots in a Range asks you to count integers in an inclusive range that equal a nonnegative integer raised to the given positive power, including zero.
Statement
Given three integers l, r, and k, return the number of integers in the inclusive range [l, r] that can be represented as nk for some integer n≥0.
Constraints:
0≤l≤r≤109
1≤k≤30
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Count K-th Roots in a Range
1.
For the input l = 0, r = 0, and k = 1, how many integers in the range can be represented as n1 for some integer n≥0?
A.
0
B.
2
C.
1
D.
10
1 / 5
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.
Count K-th Roots in a Range asks you to count integers in an inclusive range that equal a nonnegative integer raised to the given positive power, including zero.
Statement
Given three integers l, r, and k, return the number of integers in the inclusive range [l, r] that can be represented as nk for some integer n≥0.
Constraints:
0≤l≤r≤109
1≤k≤30
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Count K-th Roots in a Range
1.
For the input l = 0, r = 0, and k = 1, how many integers in the range can be represented as n1 for some integer n≥0?
A.
0
B.
2
C.
1
D.
10
1 / 5
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.