Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 397 Bytes

372.md

File metadata and controls

19 lines (17 loc) · 397 Bytes

372. Super Pow

Solution 1 (time O(n), space O(1))

class Solution(object):
    def superPow(self, a, b):
        """
        :type a: int
        :type b: List[int]
        :rtype: int
        """
        mod = 1337
        ans = 1
        for e in reversed(b):
            ans = ans * pow(a, e, mod) % mod
            a = pow(a, 10, mod)
        return ans