X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Perfect Cubes in a Range
Basic Accuracy: 24.99% Submissions: 148 Points: 1

Given two given numbers a and b where 1<= a <= b, find the perfect cubes between a and b (a and b inclusive).

Example 1:

Input: a = 1, b = 100
Output: 1 8 27 64
Explaination: These are the proper cubes between 
1 and 100.

Example 2:

Input: a = 24, b = 576
Output: 27 64 125 216 343 512
Explaination: These are the proper cubes between 
24 and 576.

Your Task:
You do not need to read input or print anything. Your task is to complete the function properCubes() which takes a and b as input parameters and returns the proper cubes between a and b. The function returns -1 if there is no proper cube between the given values.

Expected Time Complexity: O(cuberoot(b))
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ a ≤ b ≤ 104
 

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


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?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Perfect Cubes in a Range

Output Window