Super Pow

Problem: Super Pow

Code in Python:

class Solution(object):
    def superPow(self, a, b):
        """
        :type a: int
        :type b: List[int]
        :rtype: int
        """
        num = int(''.join([str(n) for n in b]))

        a %= 1337
        result = 1
        while num > 0:
            if num % 2 == 1:
                result = (result * a) % 1337
            num = num >> 1
            a = (a * a) % 1337
        return result

results matching ""

    No results matching ""