Talentd
FleetCode

372. Super Pow

Medium37.3% acceptance4 companies

Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of 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

Constraints:

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

Asked at 4 companies

9:56
Still stuck?Read 3 approaches, or watch a walkthrough.
Open solution

Similar problems

Pow(x, n)Medium
Loading editor…
1class Solution:
2 def superPow(self, a: int, b: List[int]) -> int:
3
Starter codePython 3Spaces: 4
Examples
Input
2
[3]
Input
2
[1,0]
Input
1
[4,3,3,8,5,2]
Your code is saved on this device.Solution