Skip to content

Commit 36dc424

Browse files
committed
Add support for testing negative perfect cubes
1 parent 474771e commit 36dc424

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

maths/perfect_cube.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def perfect_cube_binary_search(n: int) -> bool:
2828
...
2929
TypeError: '<=' not supported between instances of 'int' and 'str'
3030
"""
31+
if n < 0:
32+
n = -n
3133
left = 0
3234
right = n
3335
while left <= right:

0 commit comments

Comments
 (0)