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: Slice the entire string in reverse order.
1) Return a slicing of the entire input string, but with a negated step parameter
def reverse_string(myStr):
return myStr[::-1]
# OR
def reverse_string(myStr):
reversed_str = ''
for char in myStr:
reversed_str = char + reversed_str
return reversed_str