When the exponent is too large to fit in an integer, break it into pieces. Use to process one digit at a time.
Modular exponentiation is your friend. Apply modulo after every multiplication to keep numbers small and avoid overflow.
Recursion simplifies digit-by-digit processing. Each recursive call handles one digit, and the base case handles the empty array.