Medium

Quiz

#372 Super Pow

APPROACH

Compute ab modulo 1337. Here a is a positive integer while the enormous exponent b is represented digit-by-digit as an array.

Example 1:

Input: a = 2, b = [3]
Output: 8

Example 2:

Input: a = 2, b = [1,0]
Output: 1024

Example 3:

Input: a = 1, b = [4,3,3,8,5,2]
Output: 1
1 of 4
1:00

What is the optimal approach for this problem?