st0le
5/11/2013 - 5:03 AM

Naive Rotation Point

Naive Rotation Point

import random
L = 10
lst = [random.randint(0,100) for _ in xrange(L)]
lst.sort()
K = random.randint(0,L)
lst = lst[K:] + lst[:K] # rotate by random K

def find_rotation_naive(L):
    for i in xrange(len(L) - 1):
		if L[i] > L[i+1]:
			return i + 1
	return 0