Super Pow

Your task is to calculate a^b mod 1337, where a is a positive integer and b is an extremely large positive integer given in the form of an array.

Return the value of a^b mod 1337.

Example 1
Inputa = 2, b = [3]
Output8
Since b represents 3, 2^3 mod 1337 is 8.
Example 2
Inputa = 2, b = [1,0]
Output1024
Since b represents 10, 2^10 mod 1337 is 1024.

Constraints

  • 1 <= a <= 2^31 - 1
  • 1 <= b.length <= 2000
  • 0 <= b[i] <= 9
  • b does not contain leading zeros.

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate