Implement palindrome check and valid parentheses | Boston Interview Question