educative.io

Educative

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

so, i think the answer is wrong

2 Likes

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.

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’.

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.