We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d9d87d commit 8449d79Copy full SHA for 8449d79
1 file changed
sorts/cyclic_sort.py
@@ -45,11 +45,13 @@ def cyclic_sort(nums: list[int]) -> list[int]:
45
n = len(nums)
46
47
if n != len(set(nums)):
48
- raise ValueError(f"All numbers must be unique, got {nums}")
+ msg = f"All numbers must be unique, got {nums}"
49
+ raise ValueError(msg)
50
51
for num in nums:
52
if num < 1 or num > n:
- raise ValueError(f"All numbers must be in range 1 to {n}, got {num}")
53
+ msg = f"All numbers must be in range 1 to {n}, got {num}"
54
55
56
# and then sort
57
index = 0
0 commit comments