Find the second smallest on array.
Sigiloso
That's a good solution but it takes N Log N time and Log N space (because sort uses merge sort most of the time AFAIK). imo, a better solution would be to iterate the array for a min value, then iterate it again remembering the previous min index so you can ignore it. This solution would be 2n time complexity and constant memory. I'm making an assumption that all integers are unique in this case as [0, 0, 1] for my algorithm would return 0 but on the second index here. Even in the above solution this would be a problem. My algorithm can be adopted to remember the previous val if this matters and only return a different min value.