Apple interview question

Palindrome leetcode question standard solution.