In this assignment, you'll design and implement one of the common 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 that checks if the input string is a palindrome. The method should return true, if the input string is a palindrome and return false, if it is not a palindrome.
- Do not alter the input string.
- Find a solution that optimizes the space complexity as much as possible. In other words, check if your algorithm can avoid duplicating the original string.
- Share and explain the time and space complexities for your solution in the comments above the method.
- If you describe the complexity in terms of n, be sure to explain what n stands for.
- Palindrome is a word, phrase or sentence that reads the same backwards as it does forwards. e.g. "madam"
- For this exercise purposes, white spaces are ignored while checking for a palindrome string.
Notes:
- Do not use any Ruby provided methods available in the String class.
- You may use
.length
method in the String class. - You may retrieve a character at a given index, or update a character at a given index using any available approach.