Implement fast power and k-palindrome | Meta Interview Question