← Back to context

Comment by kleiba2

10 hours ago

I think the small_numbers array would differ after the end of the loop if, for instance, numbers contained only numbers >= 500. Am I wrong?

smlen would be 0 for both if there are no small numbers, so end result of both is an empty array.

For the first version small_numbers[0] will contain an arbitrary value at the end, and for the second version it happens to contain the last number read, but that address is outside of the 0-length array being returned.