bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 372. Super Pow

372. Super Pow

Leetcode Solutions

Modular Exponentiation by Digit

  1. Initialize result to 1 and current_power to a mod 1337.
  2. Iterate over the array b in reverse order.
  3. For each digit d in b, compute result = (result * (current_power^d mod 1337)) mod 1337.
  4. Update current_power to (current_power^10) mod 1337 for the next iteration.
  5. After the loop, return result as the final answer.
UML Thumbnail

Recursive Modular Exponentiation

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...