Compare two lists to see if one is a rotation of the other 2
If you compare one of the lists with all the rotations of the other list, this will take \$\Theta(n^2)\$ in the worst case.

For example, if we make test cases like this:

from timeit import timeit
def test(n):
    l1 = [0] * n
    l2 = [0] * (n - 1) + [1]
    return timeit(lambda:is_rotated(l1, l2), number=1)


then the quadratic runtime can be clearly seen in the timings:

&gt;&gt;&gt; test(10**3)
0.009426131844520569
&gt;&gt;&gt; test(10**4)
0.5701698779594153
&gt;&gt;&gt; test(10**5)
57.70295810396783


There are a couple of ways to solve this problem in linear time:


Search for one list in the concatenation of the other list with itself, using a search algorithm that has linear time in the worst case, for example Knuth–Morris–Pratt.

Here's an illustration of this approach using strings instead of lists:

&gt;&gt;&gt; a, b = 'basketwork', 'workbasket'
&gt;&gt;&gt; a in b + b
True

Find the lexicographically minimal rotation of each of the lists to be compared (for example using Booth's algorithm) and see if the results are the same.