By Long Luo

This problem is to find a integer raised to the power a very large number whose length may be $200$ or more.

# Brute Froce

We multiply $a$ to itself $b$ times. That is, $a^b = a \times a \times a \times ... \times a$(b occurrences of a). A simple java implementation of that would be:

## Analysis

• Time Complexity: $O(10^mb_i)$$m$ is the length of array b.
• Space Complexity: $O(1)$

Obiviously, it will over time, so we must find a more efficiently algorithm.

# Binary Exponentiation

Recall the 50. Pow(x, n), we develop a fast power algorithm, so we can use it here.

We didn’t need to change the method of fast power.

## Analysis

• Time Complexity: $O(\sum\limits_{i=0}^{m-1} \log b_i)$, $m$ is the length of array $b$.
• Space Complexity: $O(1)$

All suggestions are welcome.
If you have any query or suggestion please comment below.
Please upvote👍 if you like💗 it. Thank you:-)

Explore More Leetcode Solutions. 😉😃💗