Used already implemented reverseString API for determining palindrome, slightly changed for condition