Update solution.py

Solution found in O(N) time