Skip to content

Instantly share code, notes, and snippets.

@st0le
Created May 18, 2013 04:41
Show Gist options
  • Save st0le/5603269 to your computer and use it in GitHub Desktop.
Save st0le/5603269 to your computer and use it in GitHub Desktop.
max_diff_linear
def max_diff_linear(L):
min_index = 0
max_diff = start = end = 0
for i in xrange(len(L)):
if L[i] < L[min_index]: min_index = i
if max_diff < L[i] - L[min_index]:
max_diff = L[i] - L[min_index]
start,end = min_index,i
return max_diff,start,end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment