Trains the technique from
LeetCode 3932Count K-th Roots in a RangeThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Given l, r and k, count the whole numbers x at or above zero for which x raised to the power k is at least l and at most r.
Example 1
The cubes landing between 17 and 4913 run from 3 cubed, which is 27, up to 17 cubed, which is 4913, so fifteen bases qualify.
Example 2
The squares in range are 100 and 121, from the bases 10 and 11.
Example 3
No square lands between 101 and 120, since the nearest are 100 just below and 121 just above.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_kth_roots(l: int, r: int, k: int) -> int:public int countKthRoots(int l, int r, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.