Unit 3 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Slide the input string into two components and then combine them at the end.
1) Slice the second half of the string (the characters from n onward)
2) Slice the first half of the string (the characters up to n)
3) Return these two components added together in the order: second, first
def rotate_left(s, n):
return s[n:] + s[:n]