The question is simple. You want to find the difference of the maximum and the minimum. The only trick is that the bigger number should come after the smaller number.

So, here is how I tackled it. Instead of going forward, I scanned through the list of prices backward to store the current maximum number. Update the biggest difference along the way.

```
class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
length = len(prices)
if length==0:
return 0
temp = prices[length-1]
res = 0
for i in range(length-1,-1,-1):
temp = max(temp,prices[i])
if temp - prices[i] > res:
res = temp - prices[i]
return res
```