Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

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 ≤ 10^{4}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Perfect Cubes in a Range

...