Modular Exponentiation for large numbers
Implement pow(x, n) % M.
In other words, given x, n and M, find (xn) % M.
- Time : O(logn)
- Space : O(1)
1 | class Solution |
Modular Exponentiation for large numbers
Implement pow(x, n) % M.
In other words, given x, n and M, find (xn) % M.
1 | class Solution |