In this assignment, you'll design and implement one of the string manipulation functions. Remember that a string is an array of characters. Algorithms that worked on array data structure will work on strings as well.
- Design and implement a method to reverse a string in place. The method takes the string to be reversed as input parameter.
- Above the method, elaborate the comment to share the time and space complexity of your method.
- Your solution should optimize the space complexity as much as possible. In other words, do not use any more space than needed.
- If you explain the complexity in terms of n, be sure to explain what n stands for.
- For example, if the method is called with input parameter of "Lovelace", the method should update the input string object to have the value "ecalevoL".
- Notes:
- Do not use Ruby provided functionality for
.reverse
and.reverse!
. - You may use
.length
method available in the String class. - You may access a character at a given index or set the value at a given index.
- Do not use Ruby provided functionality for