Implement fast power and k-palindrome | Meta Coding Question