Added an o(n) solution, but it requires at least 1 positive integer.