Re:Solving Algorithmic Problems in Python with Pytest (2019)
by mlthoughts2018 on Saturday December 19, 2020 @08:11AM
(#25477192)
The stated problem requires returning the smallest integer greater than 0 in the list. 0 will only be the running minimum if only non-positive numbers have been seen so far, and since i is greater than zero in the condition, if minimum == 0 it means i is the first positive integer we’ve seen, so even though i > minimum (i > 0) we need to swap i as the minimum at that point.
[ Parent
| on HN ]
Re:Solving Algorithmic Problems in Python with Pytest (2019)
by rational_indian on Monday December 21, 2020 @07:02AM
(#25494111)
Thanks, that explains it.