educative.io

The question don't said the numbers taken from the range 1 to ‘n’

so, i think the answer is wrong

1 Like

the python3 answer should return len(nums) + 1

And here Ive been brekaing my head trying to cyclic sort this input [100, 99,101, 103, 107, 105, 106]. I am sorry to say but to be honest this course is a bit of a let down, no comments from course creators, sometimes improper question statements and at places not detailed enough explanations for time complexity calculations.

1 Like

Can you give a sample output and expected answer where you think the solution is wrong? The input doesn’t need to be taken from the range ‘1’ to ‘n’.

@simran, can you please specify your concern? What are you trying to do, are you seeing some incorrect result from the solution?

To clarify, let’s say if our input array is [32, 33], what is the smallest positive number missing in it?

The answer is ‘1’ and not ‘33’. Positive numbers start with ‘1’.

2 Likes

Thanks for answering. You’re correct, I assumed that the first element of the array will be the lowest number and tried to apply cyclic sort.
It would be great if you could stick around to answer more questions as that greatly helps. Thank you.

2 Likes

And the case if all numbers are negative??

@Othman_EL-KOURD, what do you think the answer will be if the array contains only negative numbers? What will be the smallest positive number missing in it?