Math Fundamentals18 sections · 814 units
Open in Course

Problem - Super Pow

LeetCode 372

Compute abmod1337a^b \mod 1337 where aa is an integer and bb is a large number represented as an array of digits.

For example, a=2a = 2 and b=[1,0]b = [1, 0] means b=10b = 10. You need 210mod1337=10242^{10} \mod 1337 = 1024.

The array bb can have thousands of digits, so you can't convert it to an integer directly. You need a way to compute the exponent piece by piece.