Learn
We’ll continue our theme of list rotation by flipping the problem: given a sorted list rotated k
times, return the index where the “unrotated” list would begin.
rotated_list = ['c', 'd', 'e', 'f', 'a'] rotation_point(rotated_list) # index 4 # a sorted list would start with 'a' another_rotated_list = [13, 8, 9, 10, 11] rotation_point(rotated_list) # index 1 # a sorted list would start with 8
Clarifying Questions:
- Are there constraints on time or space efficiency?
- No! Any solution will do.
- Does the rotation direction matter?
- This won’t affect the return value.
- What if the input isn’t rotated?
- Return 0.
Instructions
1.
Write a function rotation_point()
which has one parameter rotated_list
.
rotation_point()
should return the index where the sorted list would begin.
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.